docker / go-events

Composable event distribution for Go
Apache License 2.0
131 stars 22 forks source link

retry: implement exponential backoff for event retry #7

Closed stevvooe closed 8 years ago

stevvooe commented 8 years ago

To complement circuit breaker, we now have an exponential backoff retry strategy. The common increasing bound strategy is implemented.

A small bug was exposed in the implementation that blocked the retry forever if the strategy did not probe. Now, we simply wait for the retry and proceed. This may change behavior in the breaker case, but is more correct.

Signed-off-by: Stephen J Day stephen.day@docker.com

cc @diogomonica @aluzzardi @aaronlehmann

aaronlehmann commented 8 years ago

Not related to this PR specifically: I was looking at RetryingSink.Write for context, and saw that it it creates a new timer when Proceed returns, waits for that timer to fire, and then resets it before the next time it's used. It would be slightly simpler to use <-time.After(backoff) in the select statement. Then there would be no need to manager the lifecycle of a timer object.

aaronlehmann commented 8 years ago

LGTM. Noted minor nits.

stevvooe commented 8 years ago

I was looking at RetryingSink.Write for context, and saw that it it creates a new timer when Proceed returns, waits for that timer to fire, and then resets it before the next time it's used. It would be slightly simpler to use <-time.After(backoff) in the select statement. Then there would be no need to manager the lifecycle of a timer object.

8

aaronlehmann commented 8 years ago

Thanks. Now this one needs a simple rebase.