computeLength calculate the size of the body and the metadata.
()
| 228 | |
| 229 | // computeLength calculate the size of the body and the metadata. |
| 230 | func (item *BulkIndexerItem) computeLength() error { |
| 231 | if item.Body != nil { |
| 232 | n, err := item.Body.Seek(0, io.SeekEnd) |
| 233 | if err != nil { |
| 234 | return err |
| 235 | } |
| 236 | item.payloadLength += int(n) |
| 237 | _, err = item.Body.Seek(0, io.SeekStart) |
| 238 | if err != nil { |
| 239 | return err |
| 240 | } |
| 241 | } |
| 242 | item.payloadLength += len(item.meta.Bytes()) |
| 243 | // Add one byte to account for newline at the end of payload. |
| 244 | item.payloadLength++ |
| 245 | |
| 246 | return nil |
| 247 | } |
| 248 | |
| 249 | // BulkIndexerResponse represents the Elasticsearch response. |
| 250 | type BulkIndexerResponse struct { |