elasticsearch-rs
elasticsearch-rs copied to clipboard
[ENHANCEMENT] Support clone for BulkOperation and similar structs
Is your feature request related to a problem? Please describe.
I am needing to implement retry logic for my requests as we're very occasionally encountering 502s on AWS. For most requests this can be done fairly easily, as .body() can take a borrowed value.
However, Bulk requests require taking ownership of the Vec<BulkOperation<..>>, and additionally BulkOperation doesn't implement clone – so the only way around this is to make your own bulk operation struct that can be cloned then converted.
Describe the solution you'd like There are a few possible solutions of varying complexity and effort required:
- implementing exponential back off within the crate itself
- make
NdBodytake a reference to the body vec, rather than ownership - simply derive
CloneonBulkOperation(and maybe other structs of similar usage)
I'd happily provide a PR for the last two, although the first is certainly a far more complex solution that mightn't be desired.