mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-09 08:56:54 -04:00
Move Rows here
This is done to prevent the circular dependency. I don't like this solution but it works for now.
This commit is contained in:
parent
3cd1eb7fde
commit
34224dacff
1 changed files with 13 additions and 4 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue