call is a convenience method that allows the kafkaWriteBuffer to be used in a functional manner. This is helpful when building nested structures, as the return value can be fed into other fwWB APIs.
(cb func(wb *kafkaWriteBuffer))
| 243 | // nested structures, as the return value can be fed into |
| 244 | // other fwWB APIs. |
| 245 | func (f *kafkaWriteBuffer) call(cb func(wb *kafkaWriteBuffer)) []byte { |
| 246 | cb(f) |
| 247 | bs := f.Bytes() |
| 248 | if bs == nil { |
| 249 | bs = []byte{} |
| 250 | } |
| 251 | return bs |
| 252 | } |
| 253 | |
| 254 | func mustCompress(bs []byte, codec compress.Codec) (res []byte) { |
| 255 | buf := bytes.Buffer{} |