Skip to content

Commit

Permalink
improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maciuszek committed Dec 30, 2024
1 parent 446188d commit c3b9a08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions net_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ func (w *sinkWriter) Write(p []byte) (int, error) {
}

func (s *netSink) Flush() {
// forcefully flush the buffer to outc which will send immediately if batching is disabled
// forcefully flush the buffer to outc which will start sending immediately if batching is disabled
if s.flush() != nil {
return // nothing we can do
}
ch := make(chan struct{})
s.doFlush <- ch // send collected outc batches
s.doFlush <- ch // send collected outc batches and anything pre-batched in outc
<-ch
}

Expand Down Expand Up @@ -280,12 +280,12 @@ func (s *netSink) run() {

batchSize := GetSettings().BatchSize
isBatchEnabled := batchSize > 0
batch := make([]bytes.Buffer, 0, batchSize) // todo do we need to worry about cap(s.outc)? it's a buffered channel but the read is one at a time anyway
batch := make([]bytes.Buffer, 0, batchSize) // todo do we need to worry about cap(s.outc)? it's a buffered channel but the write to batch, is one at a time anyway

t := time.NewTicker(flushInterval)
defer t.Stop()

// flush all buffered stats and send loop
// flush all/any buffered stats (on specified ticker) and send loop
for {
// writeToConn will set s.conn to nil on error, try to reconnect
if s.conn == nil {
Expand Down
4 changes: 2 additions & 2 deletions stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (s *statStore) validateTags(tags map[string]string) {
}
}

// buffer stats loop (force flushing once per stack) on the specified ticker
// buffer stats loop (forced flushing the buffer and sending all once per itteration) on the specified ticker
func (s *statStore) StartContext(ctx context.Context, ticker *time.Ticker) {
for {
select {
Expand Down Expand Up @@ -396,7 +396,7 @@ func (s *statStore) Flush() {

flushableSink, ok := s.sink.(FlushableSink)
if ok {
flushableSink.Flush() // flushes buffer to outc which sends immediately if batching is disabled, also signals doFlush to send batched outc data if batching is enabaled
flushableSink.Flush() // flushes buffer to outc which starts sending immediately if batching is disabled, also signals doFlush to send batched outc data if batching is enabaled
}
}

Expand Down

0 comments on commit c3b9a08

Please sign in to comment.