Netflix / dispatch

All of the ad-hoc things you're doing to manage incidents today, done for you, and much more!
Apache License 2.0
4.84k stars 476 forks source link

Skip retries for defined SlackAPIErrorCode #4913

Closed jschroth closed 2 weeks ago

jschroth commented 2 weeks ago

Does not retry for any item in the SlackAPIErrorCode enum

wssheldon commented 2 weeks ago

You should be able to simplify this down to:

def should_retry(exception: Exception) -> bool:
    match exception:
        case SlackApiError():
            return exception.response["error"] not in SlackAPIErrorCode.__members__.values()
        case TimeoutError() | Timeout():
            return True
        case _:
            return False
wssheldon commented 2 weeks ago

We could also implement __contains__ on DispatchEnum to allow exception.response["error"] not in SlackAPIErrorCode