Skip to content

Commit 891580c

Browse files
committed
SCFF-31 appender multithreading
1 parent 8bcda51 commit 891580c

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

eventRouting/eventrouting.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func (e *EventRouting) LogEventTotals(logTotalsTime time.Duration) {
148148

149149
//Push the event to the queue
150150
e.queue.Push(eventQueue.NewNode(*event))
151-
//e.sLAppender.AppendLogs(*event)
152151
}
153152
}()
154153
}

main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"os"
77
"time"
88

9+
"runtime"
10+
911
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/caching"
1012
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventQueue"
1113
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventRouting"
@@ -38,9 +40,7 @@ var (
3840
func main() {
3941
kingpin.Version(version)
4042
kingpin.Parse()
41-
42-
fmt.Println("this is the sumo endpoint")
43-
fmt.Println(sumoEndpoint)
43+
runtime.GOMAXPROCS(2)
4444

4545
fmt.Printf("Starting firehose-to-sumo %s \n", version)
4646

@@ -100,6 +100,8 @@ func main() {
100100
fmt.Printf("Connected to Server! Connecting to Firehose... \n")
101101

102102
firehoseClient := firehoseclient.NewFirehoseNozzle(cfClient, events, firehoseConfig)
103+
104+
//go firehoseClient.Start()
103105
err = firehoseClient.Start()
104106
if err != nil {
105107
fmt.Printf("Failed connecting to Firehose...Please check settings and try again! \n") //Log error
@@ -110,6 +112,7 @@ func main() {
110112

111113
} else {
112114
fmt.Printf("Failed connecting to the Fluentd Server...Please check settings and try again! \n") //Log error
115+
113116
}
114117

115118
defer cachingClient.Close()

sumoCFFirehose/sumoLogicAppender.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,18 @@ func (s *SumoLogicAppender) Connect() bool {
5252
func (s *SumoLogicAppender) Start() {
5353
timer := time.NewTimer(60 * time.Second)
5454
fmt.Println("Starting Appender Worker")
55+
5556
s.logStringToSend = ""
5657
for {
58+
fmt.Println("nozzle queue")
59+
fmt.Println(s.nozzleQueue.GetCount())
5760
time.Sleep(300 * time.Millisecond)
58-
if s.nozzleQueue.GetCount() > 0 {
61+
if s.nozzleQueue.GetCount() != 0 {
62+
fmt.Println("i'm on the if")
5963
s.AppendLogs()
6064
}
61-
if s.eventsBatchSize >= s.logEventsInCurrentBuffer {
65+
fmt.Println("passed first if")
66+
if s.logEventsInCurrentBuffer >= s.eventsBatchSize {
6267
s.SendToSumo(s.logStringToSend)
6368
s.logEventsInCurrentBuffer = 0 // reset counter
6469
s.logStringToSend = "" //reset String
@@ -67,6 +72,8 @@ func (s *SumoLogicAppender) Start() {
6772
s.logEventsInCurrentBuffer = 0 // reset counter
6873
s.logStringToSend = "" //reset String
6974
}
75+
fmt.Println("passed second if")
76+
fmt.Println("end of bucle")
7077

7178
}
7279
}

0 commit comments

Comments
 (0)