From 4de48935bd2b7be879a83922bdf77ced2feab7d1 Mon Sep 17 00:00:00 2001 From: snoop Date: Thu, 9 Nov 2017 18:02:37 +0900 Subject: [PATCH] added Config Manager model --- modules/config/model/Config.go | 54 ++++++++++++++++++++++++++++++++++ modules/config/util/Util.go | 15 ++++++++++ 2 files changed, 69 insertions(+) create mode 100644 modules/config/model/Config.go create mode 100644 modules/config/util/Util.go diff --git a/modules/config/model/Config.go b/modules/config/model/Config.go new file mode 100644 index 0000000..ba6911d --- /dev/null +++ b/modules/config/model/Config.go @@ -0,0 +1,54 @@ +package model + + +type Connection struct { + Ip string `json:"ip,omitempty"` + Port string `json:"port,omitempty"` + PortType string `json:"portType,omitempty"` + SSL bool `json:"ssl,omitempty"` +} + +type Target struct { + Auth map[string]interface{} `json:"auth,omitempty"` + Connection Connection `json:"connection,omitempty"` +} + +type Schedule struct { + Interval string `json:"interval,omitempty"` +} + +type Keys struct { + Metric string `json:"metric,omitempty"` + Key string `json:"key,omitempty"` +} + +type QueryInfo struct { + Query string `json:"query,omitempty"` + Extend map[string]interface{} `json:"extend,omitempty"` +} + +type MappingInfo struct { + ParseDirection string `json:"parseDirection,omitempty"` + ArrayColumns []string `json:"arrayColumns,omitempty"` + KeyColumns []string `json:"keyColumns,omitempty"` + ValueColumn string `json:"valueColumn,omitempty"` +} + +type Item struct { + Keys []Keys `json:"keys,omitempty"` + QueryInfo QueryInfo `json:"queryInfo,omitempty"` + MappingInfo MappingInfo `json:"mappingInfo,omitempty"` +} + +type Crawler struct { + Name string `json:"name,omitempty"` + Container string `json:"container,omitempty"` +} + +type Config struct { + Id string `json:"id,omitempty"` + Target Target `json:"target,omitempty"` + Schedule Schedule `json:"schedule,omitempty"` + Crawler Crawler `json:"crawler,omitempty"` + Items []Item `json:"items,omitempty"` +} diff --git a/modules/config/util/Util.go b/modules/config/util/Util.go new file mode 100644 index 0000000..00368c8 --- /dev/null +++ b/modules/config/util/Util.go @@ -0,0 +1,15 @@ +package util + +import "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + +func KeysToMap(keys []model.Keys) map[string]string { + + m := make(map[string]string) + + + for _, key := range keys { + m[key.Key] = key.Metric + } + + return m +} \ No newline at end of file