.
This commit is contained in:
parent
d4d98d14a2
commit
d444ac72de
37
config_manager/config.go
Normal file
37
config_manager/config.go
Normal 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"`
|
||||
}
|
7
config_manager/config_manager.go
Normal file
7
config_manager/config_manager.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package config_manager
|
||||
|
||||
type ConfigManager interface {
|
||||
GetGlobalConfig() GlobalConfig
|
||||
GetCrawler(id string) Config
|
||||
}
|
||||
|
18
config_manager/global_config.go
Normal file
18
config_manager/global_config.go
Normal 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
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user