@@ -7,20 +7,22 @@ import (
77 "net/http"
88 "time"
99
10- . "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/events "
10+ "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventQueue "
1111)
1212
1313type SumoLogicAppender struct {
1414 url string
1515 connectionTimeout int //10000
1616 httpClient http.Client
17+ nozzleQueue eventQueue.Queue
1718}
1819
19- func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int ) * SumoLogicAppender {
20+ func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue eventQueue. Queue ) * SumoLogicAppender {
2021 return & SumoLogicAppender {
2122 url : urlValue ,
2223 connectionTimeout : connectionTimeoutValue ,
2324 httpClient : http.Client {Timeout : time .Duration (connectionTimeoutValue * int (time .Millisecond ))},
25+ nozzleQueue : nozzleQueue ,
2426 }
2527}
2628
@@ -41,7 +43,10 @@ func (s *SumoLogicAppender) Connect() bool {
4143 return success
4244}
4345
44- func (s * SumoLogicAppender ) AppendLogs (event Event ) {
46+ func (s * SumoLogicAppender ) AppendLogs () {
47+ // the appender calls for the next message in the queue and parse it to a string
48+ fmt .Println ("i'm in appendLogs" )
49+ event := s .nozzleQueue .Pop ().GetNodeEvent ()
4550 /*
4651 if event == nil {
4752 return
@@ -55,7 +60,8 @@ func (s *SumoLogicAppender) AppendLogs(event Event) {
5560 return
5661 }
5762
58- Message := /*strconv.Itoa(fields["timestamp"]) + */ "\t " + event .Fields ["message_type" ].(string ) + "\t " + event .Msg
63+ Message := time .Unix (0 , event .Fields ["timestamp" ].(int64 )* int64 (time .Nanosecond )).String () + "\t " + event .Fields ["message_type" ].(string ) + "\t " + event .Msg + "\n "
64+ fmt .Println (Message )
5965 s .SendToSumo (Message )
6066}
6167
0 commit comments