Since it's difficult to wrap all possible go-mastodon API calls in a backoff
algorithm outside of the package itself, I decided to implement a simple
version of it in go-mastodon's doAPI itself.
This works nicely, but could be improved in two ways still:
Abort sleeping when context gets cancelled
Make backoff optional / configurable
Personally, I still think this is a good start and probably fits most of
go-mastodon's use-cases. It certainly beats string-grepping for status code
"429" in clients.
Coverage decreased (-0.8%) to 90.075% when pulling 4ce6794dc5a1cf1c427fb69e8eeab9199d46264f on muesli:backoff into e804ee7eb264c7bbd58ad9c80291e4d9e2c131a5 on mattn:master.
Since it's difficult to wrap all possible go-mastodon API calls in a backoff algorithm outside of the package itself, I decided to implement a simple version of it in go-mastodon's doAPI itself.
This works nicely, but could be improved in two ways still:
Personally, I still think this is a good start and probably fits most of go-mastodon's use-cases. It certainly beats string-grepping for status code "429" in clients.