This commit is contained in:
geek 2017-05-16 15:29:43 +09:00
parent 624e73c186
commit 0df5921614
2 changed files with 13 additions and 6 deletions

View File

@ -3,7 +3,7 @@ package event_sender_go
import ( import (
"context" "context"
"google.golang.org/grpc" "google.golang.org/grpc"
"loafle.com/overflow/agent_api/observer/messages" //"loafle.com/overflow/agent_api/observer/messages"
pb "loafle.com/overflow/crawler_go/grpc" pb "loafle.com/overflow/crawler_go/grpc"
q "loafle.com/overflow/queue_go" q "loafle.com/overflow/queue_go"
"log" "log"
@ -76,6 +76,7 @@ func Start(ch chan bool) (err error) {
func Stop() (err error) { func Stop() (err error) {
es := GetInstance() es := GetInstance()
es.stop() es.stop()
return nil
} }
func AddEventData(event interface{}) { func AddEventData(event interface{}) {
es := GetInstance() es := GetInstance()

View File

@ -1,8 +1,8 @@
package event_sender_go package event_sender_go
import ( import (
"loafle.com/overflow/agent_api/observer" //"loafle.com/overflow/agent_api/observer"
"loafle.com/overflow/agent_api/observer/messages" //"loafle.com/overflow/agent_api/observer/messages"
"log" "log"
"strconv" "strconv"
"testing" "testing"
@ -11,8 +11,13 @@ import (
func TestEventSender_Start(t *testing.T) { func TestEventSender_Start(t *testing.T) {
observer.Notify("CONFIGMANAGER_LOADED", nil) //observer.Notify("CONFIGMANAGER_LOADED", nil)
c := make(chan bool)
err := Start(c)
if err != nil {
log.Println("err: ", err)
}
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)
testNotify() testNotify()
@ -23,6 +28,7 @@ func TestEventSender_Start(t *testing.T) {
func testNotify() { func testNotify() {
//time.Sleep(time.Second * 5) //time.Sleep(time.Second * 5)
//es := GetInstance()
for i := 0; i < 20; i++ { for i := 0; i < 20; i++ {
result := make(map[string]string) result := make(map[string]string)
@ -34,8 +40,8 @@ func testNotify() {
SensorId: "insanity", SensorId: "insanity",
Data: result, Data: result,
} }
AddEventData(cd)
observer.Notify(messages.QUEUE_EVENT, cd) //observer.Notify(messages.QUEUE_EVENT, cd)
} }
log.Println("New data Notify") log.Println("New data Notify")
} }