diff --git a/configobject/configobject.go b/configobject/configobject.go index 46d30324..279013d0 100644 --- a/configobject/configobject.go +++ b/configobject/configobject.go @@ -1,10 +1,2 @@ package configobject -type Row interface { - InsertValues() []interface{} - UpdateValues() []interface{} - GetId() string - SetId(id string) -} - -type RowFactory func() Row diff --git a/configobject/host.go b/configobject/host.go index 33a0039f..3e98301c 100644 --- a/configobject/host.go +++ b/configobject/host.go @@ -51,7 +51,7 @@ type Host struct { CommandEndpointId string `json:"command_endpoint_id"` } -func NewHost() Row { +func NewHost() icingadb_json_decoder.Row { h := Host{ EnvId: icingadb_utils.DecodeChecksum(icingadb_utils.Sha1("default")), CheckPeriod: "check_period", @@ -64,13 +64,13 @@ func NewHost() 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( @@ -146,6 +146,7 @@ func HostOperator(super *supervisor.Supervisor) error { Id: icingadb_utils.Bytes2checksum(icingadb_utils.Checksum(id)), ChecksumsRaw: value, ChBack: chBack, + Factory:NewHost, } super.ChDecode <- &pkg diff --git a/main.go b/main.go index 26e9856f..c85defe2 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,13 @@ package main import ( + "encoding/hex" "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/supervisor" + "log" ) func main() { @@ -21,14 +23,14 @@ func main() { } super := supervisor.Supervisor{ - ChEnv: make(chan *icingadb_connection.Environment), + ChEnv: make(chan *icingadb_ha.Environment), ChDecode: make(chan *icingadb_json_decoder.JsonDecodePackage), Rdbw: redisConn, Dbw: mysqlConn, } ha := icingadb_ha.HA{} - ha.Run(super.Rdbw, super.Dbw, super.ChEnv, chErr) + go ha.Run(super.Rdbw, super.Dbw, super.ChEnv, chErr) go func() { chErr <- icingadb_ha.IcingaEventsBroker(redisConn, super.ChEnv) }() diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go index a02c80d0..0a0f5aa3 100644 --- a/supervisor/supervisor.go +++ b/supervisor/supervisor.go @@ -3,11 +3,12 @@ package supervisor import ( "git.icinga.com/icingadb/icingadb-connection" "git.icinga.com/icingadb/icingadb-json-decoder" + "git.icinga.com/icingadb/icingadb-ha" ) type Supervisor struct { ChErr chan error - ChEnv chan *icingadb_connection.Environment + ChEnv chan *icingadb_ha.Environment ChDecode chan *icingadb_json_decoder.JsonDecodePackage Rdbw *icingadb_connection.RDBWrapper Dbw *icingadb_connection.DBWrapper