This commit is contained in:
jackdaw@loafle.com 2017-04-27 14:58:34 +09:00
parent d4d98d14a2
commit d444ac72de
4 changed files with 80 additions and 1 deletions

37
config_manager/config.go Normal file
View File

@ -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"`
}

View File

@ -0,0 +1,7 @@
package config_manager
type ConfigManager interface {
GetGlobalConfig() GlobalConfig
GetCrawler(id string) Config
}

View File

@ -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
}

View File

@ -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)
}