elasticsearch-rs icon indicating copy to clipboard operation
elasticsearch-rs copied to clipboard

[ENHANCEMENT] Support clone for BulkOperation and similar structs

Open oeed opened this issue 3 years ago • 0 comments

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 NdBody take a reference to the body vec, rather than ownership
  • simply derive Clone on BulkOperation (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.

oeed avatar Feb 06 '22 21:02 oeed