(msg Message, maxSize int, maxBytes int64)
| 1219 | } |
| 1220 | |
| 1221 | func (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 | |
| 1238 | func (b *writeBatch) full(maxSize int, maxBytes int64) bool { |
| 1239 | return b.size >= maxSize || b.bytes >= maxBytes |
no test coverage detected