From 34224dacff17ea72b05fbf74491ae8e23f53721c Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Thu, 7 Mar 2019 17:21:29 +0100 Subject: [PATCH] Move Rows here This is done to prevent the circular dependency. I don't like this solution but it works for now. --- json-decoder.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/json-decoder.go b/json-decoder.go index f4a2e2e4..c1f70d11 100644 --- a/json-decoder.go +++ b/json-decoder.go @@ -1,26 +1,35 @@ package icingadb_json_decoder import ( - "git.icinga.com/icingadb/icingadb-main/configobject" "github.com/json-iterator/go" ) var json = jsoniter.ConfigCompatibleWithStandardLibrary +type Row interface { + InsertValues() []interface{} + UpdateValues() []interface{} + GetId() string + SetId(id string) +} + +type RowFactory func() Row + + type JsonDecodePackage struct{ Id [20]byte // Json strings from Redis ChecksumsRaw string ConfigRaw string - Row configobject.Row + Row Row // Package will be sent back through this channel ChBack chan *JsonDecodePackage - Factory configobject.RowFactory + Factory RowFactory } // decodeString unmarshals the string toDecode using the json package. Returns the object as a // map[string]interface and nil if successful, error if not. -func decodeString(toDecode string, row configobject.Row) error { +func decodeString(toDecode string, row Row) error { return json.Unmarshal([]byte(toDecode), row) }