long poller
This commit is contained in:
parent
254b3f9392
commit
2627e114ff
|
@ -13,7 +13,6 @@ import (
|
|||
|
||||
const (
|
||||
POLLING_ID = "OVERFLOW_LONG_POLLING"
|
||||
DEFAULT_INTERVAL = uint64(3)
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -74,7 +73,6 @@ func (p *Poller) handleInterval(ch chan interface{}) {
|
|||
func (p *Poller) Stop(ch chan interface{}) {
|
||||
p.scheduler.Stop()
|
||||
p.runStat <- false
|
||||
p.removeAgentStopHandler(ch)
|
||||
}
|
||||
|
||||
func (p *Poller) polling(agentId string) {
|
||||
|
@ -113,7 +111,6 @@ func (p *Poller) updateInterval(interval string) {
|
|||
p.scheduler.UpdateInterval(POLLING_ID, uint64(i))
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
func printStatusStream(client pb.StatusClient) {
|
||||
stream, err := client.Status(context.Background(), &pb.Empty{})
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
package long_poller_go
|
||||
|
||||
import (
|
||||
"loafle.com/overflow/agent_api/observer"
|
||||
"loafle.com/overflow/agent_api/observer/messages"
|
||||
)
|
||||
|
||||
func handleConfigLoaded() {
|
||||
ch := make(chan interface{}, 0)
|
||||
observer.Add(messages.CFG_LOADED, ch)
|
||||
startPoller(ch)
|
||||
}
|
||||
|
||||
func (p *Poller) handleAgentStop() {
|
||||
ch := make(chan interface{}, 0)
|
||||
observer.Add(messages.AGT_STOPPED, ch)
|
||||
_ = <- ch
|
||||
p.Stop(ch)
|
||||
}
|
||||
|
||||
func (p *Poller) removeConfigLoadedHandler(ch chan interface{}) {
|
||||
observer.Remove(messages.CFG_LOADED, ch)
|
||||
}
|
||||
|
||||
func (p *Poller) removeAgentStopHandler(ch chan interface{}) {
|
||||
observer.Remove(messages.AGT_STOPPED, ch)
|
||||
}
|
||||
//import (
|
||||
// "loafle.com/overflow/agent_api/observer"
|
||||
// "loafle.com/overflow/agent_api/observer/messages"
|
||||
//)
|
||||
//
|
||||
//func handleConfigLoaded() {
|
||||
// ch := make(chan interface{}, 0)
|
||||
// observer.Add(messages.CFG_LOADED, ch)
|
||||
// startPoller(ch)
|
||||
//}
|
||||
//
|
||||
//func (p *Poller) handleAgentStop() {
|
||||
// ch := make(chan interface{}, 0)
|
||||
// observer.Add(messages.AGT_STOPPED, ch)
|
||||
// _ = <-ch
|
||||
// p.Stop(ch)
|
||||
//}
|
||||
//
|
||||
//func (p *Poller) removeConfigLoadedHandler(ch chan interface{}) {
|
||||
// observer.Remove(messages.CFG_LOADED, ch)
|
||||
//}
|
||||
//
|
||||
//func (p *Poller) removeAgentStopHandler(ch chan interface{}) {
|
||||
// observer.Remove(messages.AGT_STOPPED, ch)
|
||||
//}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package long_poller_go
|
||||
|
||||
import (
|
||||
"loafle.com/overflow/agent_api/observer"
|
||||
"loafle.com/overflow/agent_api/observer/messages"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPolling(t *testing.T) {
|
||||
poller := &Poller{}
|
||||
poller.start()
|
||||
}
|
||||
|
||||
func TestTotal(t *testing.T) {
|
||||
time.Sleep(time.Second * 5)
|
||||
|
||||
observer.Notify(messages.CFG_LOADED, "") //CONFIG LOCATION
|
||||
time.Sleep(time.Second * 100)
|
||||
}
|
||||
//import (
|
||||
// "loafle.com/overflow/agent_api/observer"
|
||||
// "loafle.com/overflow/agent_api/observer/messages"
|
||||
// "testing"
|
||||
// "time"
|
||||
//)
|
||||
//
|
||||
//func TestPolling(t *testing.T) {
|
||||
// poller := &Poller{}
|
||||
// poller.start()
|
||||
//}
|
||||
//
|
||||
//func TestTotal(t *testing.T) {
|
||||
// time.Sleep(time.Second * 5)
|
||||
//
|
||||
// observer.Notify(messages.CFG_LOADED, "") //CONFIG LOCATION
|
||||
// time.Sleep(time.Second * 100)
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue
Block a user