diff --git a/event_sender.go b/event_sender.go index 8a46a17..59a7929 100644 --- a/event_sender.go +++ b/event_sender.go @@ -40,6 +40,7 @@ func (es *EventSender) Start() { func (es *EventSender) Stop() { if es.sc != nil { close(es.sc) + es.sc = nil } } @@ -59,7 +60,7 @@ func (es *EventSender) checkQueue() { collectedData := tempCollectedData.Value.(*Data) collectedData.AgentId = agentIdentifier() result = append(result, collectedData) - log.Println("Result Len: ", len(result)) + //log.Println("Result Len: ", len(result)) } es.send(result) result = nil diff --git a/event_sender_test.go b/event_sender_test.go index 6183bc6..72fd92f 100644 --- a/event_sender_test.go +++ b/event_sender_test.go @@ -6,6 +6,7 @@ import ( "log" "testing" "time" + "strconv" ) func TestEventSender_Start(t *testing.T) { @@ -14,23 +15,25 @@ func TestEventSender_Start(t *testing.T) { es.Start() testNotify() - time.Sleep(time.Second * 100) + time.Sleep(time.Second * 1000) } func testNotify() { //time.Sleep(time.Second * 5) + for i := 0; i < 20; i ++{ result := make(map[string]string) - result["ab"] = "123" - result["cd"] = "456" - result["ef"] = "789" + result["ab"] = "123 ( " + strconv.Itoa(i) + ")" + result["cd"] = "456 ( "+ strconv.Itoa(i) + ")" + result["ef"] = "789 ( "+ strconv.Itoa(i) + ")" cd := &Data{ SensorId: "insanity", Data: result, } - log.Println("New data Notify") observer.Notify(messages.QUEUE_EVENT, cd) + } + log.Println("New data Notify") }