Skip to content

Commit

Permalink
add env var for alive conn send
Browse files Browse the repository at this point in the history
  • Loading branch information
kenanfarukcakir committed Aug 6, 2024
1 parent 8fe48fe commit f87c73b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aggregator/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1573,18 +1573,20 @@ func (a *Aggregator) sendOpenConnection(sl *SocketLine) {
}
}

// TODO: connection send is made here, sendOpenConnection must be called, refactor this func and its calling place
func (a *Aggregator) clearSocketLines(ctx context.Context) {
ticker := time.NewTicker(120 * time.Second)
skLineCh := make(chan *SocketLine, 1000)

sendAliveConnections, _ := strconv.ParseBool(os.Getenv("SEND_ALIVE_TCP_CONNECTIONS"))
go func() {
// spawn N goroutines to clear socket map
for i := 0; i < 10; i++ {
go func() {
for skLine := range skLineCh {
// send open connections to datastore
a.sendOpenConnection(skLine)
if sendAliveConnections {
a.sendOpenConnection(skLine)
}
// clear socket history
skLine.DeleteUnused()
}
Expand Down

0 comments on commit f87c73b

Please sign in to comment.