mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Move host into host package & readd Row into configobject package
This commit is contained in:
parent
fef7d94508
commit
af1d0c7193
3 changed files with 19 additions and 8 deletions
|
|
@ -1,2 +1,10 @@
|
|||
package configobject
|
||||
|
||||
type Row interface {
|
||||
InsertValues() []interface{}
|
||||
UpdateValues() []interface{}
|
||||
GetId() string
|
||||
SetId(id string)
|
||||
}
|
||||
|
||||
type RowFactory func() Row
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
package configobject
|
||||
package host
|
||||
|
||||
import (
|
||||
"git.icinga.com/icingadb/icingadb-json-decoder"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject"
|
||||
"git.icinga.com/icingadb/icingadb-main/supervisor"
|
||||
"git.icinga.com/icingadb/icingadb-utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type Host struct {
|
||||
|
|
@ -50,7 +52,7 @@ type Host struct {
|
|||
CommandEndpointId string `json:"command_endpoint_id"`
|
||||
}
|
||||
|
||||
func NewHost() icingadb_json_decoder.Row {
|
||||
func NewHost() configobject.Row {
|
||||
h := Host{
|
||||
EnvId: icingadb_utils.DecodeChecksum(icingadb_utils.Sha1("default")),
|
||||
CheckPeriod: "check_period",
|
||||
|
|
@ -63,13 +65,13 @@ func NewHost() icingadb_json_decoder.Row {
|
|||
return &h
|
||||
}
|
||||
|
||||
func (h Host) InsertValues() []interface{} {
|
||||
func (h *Host) InsertValues() []interface{} {
|
||||
v := h.UpdateValues()
|
||||
|
||||
return append([]interface{}{icingadb_utils.Checksum(h.Id)}, v...)
|
||||
}
|
||||
|
||||
func (h Host) UpdateValues() []interface{} {
|
||||
func (h *Host) UpdateValues() []interface{} {
|
||||
v := make([]interface{}, 0)
|
||||
|
||||
v = append(
|
||||
|
|
@ -119,11 +121,11 @@ func (h Host) UpdateValues() []interface{} {
|
|||
return v
|
||||
}
|
||||
|
||||
func (h Host) GetId() string {
|
||||
func (h *Host) GetId() string {
|
||||
return h.Id
|
||||
}
|
||||
|
||||
func (h Host) SetId(id string) {
|
||||
func (h *Host) SetId(id string) {
|
||||
h.Id = id
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +162,7 @@ func HostOperator(super *supervisor.Supervisor) error {
|
|||
hosts[ret.Id] = ret.Row.(*Host)
|
||||
count--
|
||||
if 0 == count {
|
||||
log.Info("Hosts done")
|
||||
close(chBack)
|
||||
}
|
||||
}
|
||||
4
main.go
4
main.go
|
|
@ -5,7 +5,7 @@ import (
|
|||
"git.icinga.com/icingadb/icingadb-connection"
|
||||
"git.icinga.com/icingadb/icingadb-ha"
|
||||
"git.icinga.com/icingadb/icingadb-json-decoder"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject"
|
||||
"git.icinga.com/icingadb/icingadb-main/configobject/host"
|
||||
"git.icinga.com/icingadb/icingadb-main/supervisor"
|
||||
"log"
|
||||
)
|
||||
|
|
@ -38,7 +38,7 @@ func main() {
|
|||
go icingadb_json_decoder.DecodePool(super.ChDecode, chErr, 16)
|
||||
|
||||
go func() {
|
||||
chErr <- configobject.HostOperator(&super)
|
||||
chErr <- host.HostOperator(&super)
|
||||
}()
|
||||
|
||||
for {
|
||||
|
|
|
|||
Loading…
Reference in a new issue