From d444ac72de3a764ce1ab5bdfa3457ea9ec67ddaf Mon Sep 17 00:00:00 2001 From: "jackdaw@loafle.com" Date: Thu, 27 Apr 2017 14:58:34 +0900 Subject: [PATCH] . --- config_manager/config.go | 37 ++++++++++++++++++++++++++++++++ config_manager/config_manager.go | 7 ++++++ config_manager/global_config.go | 18 ++++++++++++++++ observer/observer_test.go | 19 +++++++++++++++- 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 config_manager/config.go create mode 100644 config_manager/config_manager.go create mode 100644 config_manager/global_config.go diff --git a/config_manager/config.go b/config_manager/config.go new file mode 100644 index 0000000..1b43657 --- /dev/null +++ b/config_manager/config.go @@ -0,0 +1,37 @@ +package config_manager + + +type Auth struct { +} + +type Connection struct { + Ip string `json:"ip"` + Port string `json:"port"` + PortType string `json:"portType"` + SSL bool `json:"ssl"` +} + +type Target struct { + Auth Auth + Connection Connection +} + +type Schedule struct { + Interval string `json:"interval"` +} + +type Item struct { +} + +type Crawler struct { + Name string `json:"name"` + Container string `json:"container"` +} + +type Config struct { + Id string `json:"id"` + Target Target `json:"target"` + Schedule Schedule `json:"schedule"` + Crawler Crawler `json:"crawler"` + Items []Item `json:"items"` +} diff --git a/config_manager/config_manager.go b/config_manager/config_manager.go new file mode 100644 index 0000000..6eb5f93 --- /dev/null +++ b/config_manager/config_manager.go @@ -0,0 +1,7 @@ +package config_manager + +type ConfigManager interface { + GetGlobalConfig() GlobalConfig + GetCrawler(id string) Config +} + diff --git a/config_manager/global_config.go b/config_manager/global_config.go new file mode 100644 index 0000000..0d5db2c --- /dev/null +++ b/config_manager/global_config.go @@ -0,0 +1,18 @@ +package config_manager + + +/* global config 예제 + central: + address: "http://localhost:9090" + port: 443 + log_path: "./bin/log.xml" +*/ + + +type GlobalConfig struct { + Central struct { + Address string + Port int + } + Log_Path string +} \ No newline at end of file diff --git a/observer/observer_test.go b/observer/observer_test.go index 4fdb4da..84f2e74 100644 --- a/observer/observer_test.go +++ b/observer/observer_test.go @@ -4,6 +4,8 @@ import ( "github.com/stretchr/testify/assert" "testing" "time" + "loafle.com/overflow/agent_api/observer/messages" + "fmt" ) type Test struct { @@ -85,7 +87,7 @@ func TestMultiAddObserver(t *testing.T) { Notify("test", Test{Id: "test"}) time.Sleep(2 * time.Second) - Remove("test", ch1) + Remove(messages.CRAWLER_ADD, ch1) Remove("test", ch2) Remove("test", ch3) Remove("test", ch4) @@ -95,3 +97,18 @@ func TestMultiAddObserver(t *testing.T) { time.Sleep(1 * time.Second) } + + +func TestStringNotify(t *testing.T) { + ch := make(chan interface{},0) + Add("test",ch) + + go func() { + data :=<-ch + str := data.(string) + fmt.Println(str) + }() + + Notify("test","testsetasetaset") + time.Sleep(1 * time.Second) +}