connor4312 / cockatiel

🐦 A resilience and fault-handling library. Supports Backoffs, Retries, Circuit Breakers, Timeouts, Bulkhead Isolation, and Fallbacks.
MIT License
1.59k stars 50 forks source link

exponential doc wrong #18

Closed xenoterracide closed 4 years ago

xenoterracide commented 4 years ago

in your docs you have this

const retry = Policy.handleAll()
  .retry()
  .attempts(3)
  .exponential();

but the signature of .exponential() is

    exponential<S>(options: Partial<IExponentialBackoffOptions<S>>): RetryPolicy;

which means it's not optional, but you can provide an empty object it seems.

Thanks for making this, it seems to do exactly what I wanted, the other things I found (opossum) were making the execute harder.

side notes: opossum does have one thing, it has quite a few events that you can hook on, like halfopen, would be cool to have a larger number of events to trigger on. Also from your docs (it might be in Polly) it's unclear why I would want to chain circuitbreaker with retry, since both retry.

connor4312 commented 4 years ago

Thanks for the issue!

Corrected the exponential signature and added a half-open event. Opossum has other events as well, but some of them are not related to the state of the circuit breaker and easy to observe yourself (e.g. successes and errors can be seen easily by looking at whether or not the function throws). So I'm not sure I feel the need to add more API for those, but I'm open to pushback..

connor4312 commented 4 years ago

Actually, https://github.com/connor4312/cockatiel/issues/20 suggests good usages for these. I suppose I'll add them 😛