MCPcopy
hub / github.com/IBM/sarama / readyToFlush

Method readyToFlush

produce_set.go:335–352  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

333}
334
335func (ps *produceSet) readyToFlush() bool {
336 switch {
337 // If we don't have any messages, nothing else matters
338 case ps.empty():
339 return false
340 // If all three config values are 0, we always flush as-fast-as-possible
341 case ps.parent.conf.Producer.Flush.Frequency == 0 && ps.parent.conf.Producer.Flush.Bytes == 0 && ps.parent.conf.Producer.Flush.Messages == 0:
342 return true
343 // If we've passed the message trigger-point
344 case ps.parent.conf.Producer.Flush.Messages > 0 && ps.bufferCount >= ps.parent.conf.Producer.Flush.Messages:
345 return true
346 // If we've passed the byte trigger-point
347 case ps.parent.conf.Producer.Flush.Bytes > 0 && ps.bufferBytes >= ps.parent.conf.Producer.Flush.Bytes:
348 return true
349 default:
350 return false
351 }
352}
353
354func (ps *produceSet) empty() bool {
355 return ps.bufferCount == 0

Callers 3

runMethod · 0.80
TestProduceSetInitialFunction · 0.80

Calls 1

emptyMethod · 0.95

Tested by 2

TestProduceSetInitialFunction · 0.64