@@ -14,13 +14,13 @@ type SumoLogicAppender struct {
1414 url string
1515 connectionTimeout int //10000
1616 httpClient http.Client
17- nozzleQueue eventQueue.Queue
17+ nozzleQueue * eventQueue.Queue
1818 eventsBatchSize int
1919 logEventsInCurrentBuffer int
2020 logStringToSend string
2121}
2222
23- func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue eventQueue.Queue , eventsBatchSize int ) * SumoLogicAppender {
23+ func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue * eventQueue.Queue , eventsBatchSize int ) * SumoLogicAppender {
2424 return & SumoLogicAppender {
2525 url : urlValue ,
2626 connectionTimeout : connectionTimeoutValue ,
@@ -50,30 +50,29 @@ func (s *SumoLogicAppender) Connect() bool {
5050}
5151
5252func (s * SumoLogicAppender ) Start () {
53- timer := time .NewTimer ( 60 * time . Second )
53+ timer := time .Now ( )
5454 fmt .Println ("Starting Appender Worker" )
55-
5655 s .logStringToSend = ""
5756 for {
58- fmt .Println ("nozzle queue" )
59- fmt .Println (s .nozzleQueue .GetCount ())
6057 time .Sleep (300 * time .Millisecond )
6158 if s .nozzleQueue .GetCount () != 0 {
62- fmt .Println ("i'm on the if" )
6359 s .AppendLogs ()
60+ fmt .Println (s .logStringToSend )
6461 }
65- fmt .Println ("passed first if" )
6662 if s .logEventsInCurrentBuffer >= s .eventsBatchSize {
63+ fmt .Println ("Buffer full" )
64+ fmt .Println (s .logStringToSend )
6765 s .SendToSumo (s .logStringToSend )
6866 s .logEventsInCurrentBuffer = 0 // reset counter
6967 s .logStringToSend = "" //reset String
70- } else if (<- timer .C ).Second () == 0 {
68+ } else if time .Since (timer ).Seconds () >= 10 {
69+ fmt .Println ("timer finished, sending logs..." )
70+ fmt .Println (s .logStringToSend )
7171 s .SendToSumo (s .logStringToSend )
7272 s .logEventsInCurrentBuffer = 0 // reset counter
7373 s .logStringToSend = "" //reset String
74+ timer = time .Now () //reset timer
7475 }
75- fmt .Println ("passed second if" )
76- fmt .Println ("end of bucle" )
7776
7877 }
7978}
@@ -97,7 +96,6 @@ func (s *SumoLogicAppender) AppendLogs() {
9796 //timer := time.NewTimer(60 * time.Second)
9897 s .logStringToSend = s .logStringToSend + StringBuilder (s .nozzleQueue .Pop ())
9998 s .logEventsInCurrentBuffer ++
100-
10199}
102100
103101func (s * SumoLogicAppender ) SendToSumo (log string ) {
0 commit comments