event test
This commit is contained in:
parent
618339b086
commit
47a6698007
|
@ -3,16 +3,15 @@ package event_sender
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"loafle.com/overflow/agent_api/observer"
|
||||||
"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"
|
||||||
"reflect"
|
"reflect"
|
||||||
"loafle.com/overflow/agent_api/observer"
|
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
instance *EventSender
|
instance *EventSender
|
||||||
once sync.Once
|
once sync.Once
|
||||||
|
@ -32,7 +31,6 @@ type Data struct {
|
||||||
FinishedAt uint64
|
FinishedAt uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func GetInstance() *EventSender {
|
func GetInstance() *EventSender {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
instance = &EventSender{}
|
instance = &EventSender{}
|
||||||
|
@ -40,7 +38,7 @@ func GetInstance() *EventSender {
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
ch := make(chan interface{}, 0)
|
ch := make(chan interface{}, 0)
|
||||||
observer.Add(messages.CONFIGMANAGER_LOADED, ch)
|
observer.Add(messages.CONFIGMANAGER_LOADED, ch)
|
||||||
handleInit(ch)
|
handleInit(ch)
|
||||||
|
@ -58,9 +56,9 @@ func handleInit(ch chan interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventSender struct {
|
type EventSender struct {
|
||||||
once sync.Once
|
once sync.Once
|
||||||
lq *q.LoafleQueue
|
lq *q.LoafleQueue
|
||||||
sc chan interface{}
|
sc chan interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (es *EventSender) start() {
|
func (es *EventSender) start() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user