From 59d517cb32d6213180773f114a30109342f9ef5b Mon Sep 17 00:00:00 2001 From: "insanity@loafle.com" Date: Tue, 25 Apr 2017 16:56:04 +0900 Subject: [PATCH] long poller --- poller.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/poller.go b/poller.go index 980c67c..0dde578 100644 --- a/poller.go +++ b/poller.go @@ -1,20 +1,18 @@ package long_poller_go import ( - "fmt" + "context" "google.golang.org/grpc" "loafle.com/overflow/cron_go" + "log" "sync" - "context" pb "loafle.com/overflow/crawler_go/grpc" //temp - "log" - "time" ) var ( POLLING_ID = "OVERFLOW_LONG_POLLING" - DEFAULT_INTERVAL = uint64(5) + DEFAULT_INTERVAL = uint64(3) API_SERVER_ADDR = "127.0.0.1:50052" ) @@ -44,7 +42,6 @@ func (p *LongPoller) Stop() { } func (p *LongPoller) polling(agentId string) { - fmt.Printf("[%s] %s :: LongPolling\n", time.Now(), agentId) conn, err := grpc.Dial(API_SERVER_ADDR, grpc.WithInsecure()) if err != nil { @@ -59,7 +56,12 @@ func (p *LongPoller) polling(agentId string) { if err != nil { log.Println(err) } - log.Println(out) + + p.dispatchNotify(out) +} + +func (p *LongPoller) dispatchNotify(result interface{}) { + log.Printf("Polling result - %s ", result) } func agentIdentifier() string {