From 3f116f134376c7db92cf65bb3d9d377bd5ca4498 Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 4 Dec 2017 15:50:11 +0900 Subject: [PATCH] ing --- modules/config/model/Config.go | 54 +++---------------- modules/config/model/Connection.go | 8 +++ modules/config/model/Crawler.go | 6 +++ modules/config/model/Item.go | 7 +++ modules/config/model/Keys.go | 6 +++ modules/config/model/MappingInfo.go | 8 +++ modules/config/model/QueryInfo.go | 6 +++ modules/config/model/Schedule.go | 5 ++ modules/config/model/Target.go | 6 +++ modules/probe/service/probe/CrawlerService.go | 6 ++- .../probe/service/probe/DiscoveryService.go | 4 -- modules/probe/service/probe/SensorService.go | 14 +++-- 12 files changed, 72 insertions(+), 58 deletions(-) create mode 100644 modules/config/model/Connection.go create mode 100644 modules/config/model/Crawler.go create mode 100644 modules/config/model/Item.go create mode 100644 modules/config/model/Keys.go create mode 100644 modules/config/model/MappingInfo.go create mode 100644 modules/config/model/QueryInfo.go create mode 100644 modules/config/model/Schedule.go create mode 100644 modules/config/model/Target.go delete mode 100644 modules/probe/service/probe/DiscoveryService.go diff --git a/modules/config/model/Config.go b/modules/config/model/Config.go index 7c79086..f293d39 100644 --- a/modules/config/model/Config.go +++ b/modules/config/model/Config.go @@ -1,53 +1,11 @@ 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"` -} +import "encoding/json" 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"` + ID json.Number `json:"id,Number,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/model/Connection.go b/modules/config/model/Connection.go new file mode 100644 index 0000000..59d020f --- /dev/null +++ b/modules/config/model/Connection.go @@ -0,0 +1,8 @@ +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"` +} diff --git a/modules/config/model/Crawler.go b/modules/config/model/Crawler.go new file mode 100644 index 0000000..1da5fd7 --- /dev/null +++ b/modules/config/model/Crawler.go @@ -0,0 +1,6 @@ +package model + +type Crawler struct { + Name string `json:"name,omitempty"` + Container string `json:"container,omitempty"` +} diff --git a/modules/config/model/Item.go b/modules/config/model/Item.go new file mode 100644 index 0000000..d2dc88c --- /dev/null +++ b/modules/config/model/Item.go @@ -0,0 +1,7 @@ +package model + +type Item struct { + Keys []Keys `json:"keys,omitempty"` + QueryInfo *QueryInfo `json:"queryInfo,omitempty"` + MappingInfo *MappingInfo `json:"mappingInfo,omitempty"` +} diff --git a/modules/config/model/Keys.go b/modules/config/model/Keys.go new file mode 100644 index 0000000..decbd46 --- /dev/null +++ b/modules/config/model/Keys.go @@ -0,0 +1,6 @@ +package model + +type Keys struct { + Metric string `json:"metric,omitempty"` + Key string `json:"key,omitempty"` +} \ No newline at end of file diff --git a/modules/config/model/MappingInfo.go b/modules/config/model/MappingInfo.go new file mode 100644 index 0000000..f3b535b --- /dev/null +++ b/modules/config/model/MappingInfo.go @@ -0,0 +1,8 @@ +package model + +type MappingInfo struct { + ParseDirection string `json:"parseDirection,omitempty"` + ArrayColumns []string `json:"arrayColumns,omitempty"` + KeyColumns []string `json:"keyColumns,omitempty"` + ValueColumn string `json:"valueColumn,omitempty"` +} diff --git a/modules/config/model/QueryInfo.go b/modules/config/model/QueryInfo.go new file mode 100644 index 0000000..0a0a257 --- /dev/null +++ b/modules/config/model/QueryInfo.go @@ -0,0 +1,6 @@ +package model + +type QueryInfo struct { + Query string `json:"query,omitempty"` + Extend map[string]interface{} `json:"extend,omitempty"` +} diff --git a/modules/config/model/Schedule.go b/modules/config/model/Schedule.go new file mode 100644 index 0000000..6d6c3b3 --- /dev/null +++ b/modules/config/model/Schedule.go @@ -0,0 +1,5 @@ +package model + +type Schedule struct { + Interval string `json:"interval,omitempty"` +} diff --git a/modules/config/model/Target.go b/modules/config/model/Target.go new file mode 100644 index 0000000..b9dcdfb --- /dev/null +++ b/modules/config/model/Target.go @@ -0,0 +1,6 @@ +package model + +type Target struct { + Auth map[string]interface{} `json:"auth,omitempty"` + Connection *Connection `json:"connection,omitempty"` +} diff --git a/modules/probe/service/probe/CrawlerService.go b/modules/probe/service/probe/CrawlerService.go index cfe106d..dfc7e61 100644 --- a/modules/probe/service/probe/CrawlerService.go +++ b/modules/probe/service/probe/CrawlerService.go @@ -1,9 +1,13 @@ package probe +import ( + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" +) + type CrawlerService interface { Install() Uninstall() Update() - Authenticate() + Authenticate(crawler *configM.Crawler, target *configM.Target) (bool, error) } diff --git a/modules/probe/service/probe/DiscoveryService.go b/modules/probe/service/probe/DiscoveryService.go deleted file mode 100644 index 1a3de55..0000000 --- a/modules/probe/service/probe/DiscoveryService.go +++ /dev/null @@ -1,4 +0,0 @@ -package probe - -type DiscoveryService interface { -} diff --git a/modules/probe/service/probe/SensorService.go b/modules/probe/service/probe/SensorService.go index 3ff05c3..026abe3 100644 --- a/modules/probe/service/probe/SensorService.go +++ b/modules/probe/service/probe/SensorService.go @@ -1,9 +1,13 @@ package probe +import ( + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" +) + type SensorService interface { - Start() - Stop() - Add() - Remove() - Update() + Start(id int64) (bool, error) + Stop(id int64) (bool, error) + Add(config *configM.Config) (bool, error) + Remove(id int64) (bool, error) + Update(id int64) (bool, error) }