MCPcopy
hub / github.com/segmentio/kafka-go / add

Method add

writer.go:1221–1236  ·  view source on GitHub ↗
(msg Message, maxSize int, maxBytes int64)

Source from the content-addressed store, hash-verified

1219}
1220
1221func (b *writeBatch) add(msg Message, maxSize int, maxBytes int64) bool {
1222 bytes := int64(msg.totalSize())
1223
1224 if b.size > 0 && (b.bytes+bytes) > maxBytes {
1225 return false
1226 }
1227
1228 if cap(b.msgs) == 0 {
1229 b.msgs = make([]Message, 0, maxSize)
1230 }
1231
1232 b.msgs = append(b.msgs, msg)
1233 b.size++
1234 b.bytes += bytes
1235 return true
1236}
1237
1238func (b *writeBatch) full(maxSize int, maxBytes int64) bool {
1239 return b.size >= maxSize || b.bytes >= maxBytes

Callers 1

writeMessagesMethod · 0.80

Calls 1

totalSizeMethod · 0.80

Tested by

no test coverage detected