long poller

This commit is contained in:
insanity@loafle.com 2017-04-25 16:56:04 +09:00
parent c2b8b106ab
commit 59d517cb32

View File

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