Skip to content

RFC: base retry class for building custom retry rules #22

Description

@mharrisb1

Request for comment (RFC) for potential feature:

To allow a user to define more complex retries not available through constructor options we could provide a retry base class that has abstract methods that the user can inherit from and design.

For example, if I want infinite retries on 1XX status codes with not backoff or jitter but provide an allowance for 4XX and 5XX status codes with backoff or jitter I don't see a way to do that today.

Example:

from httpx_retries import BaseRetry, RetryTransport

class MySuperComplexRetry(BaseRetry):
    # need to clarify which abstract methods need to be defined
    ...

transport = RetryTransport(retry=MySuperComplexRetry())

An alternative already exists for this today since the user can technically just subclass Retry and override methods but this may present a cleaner option so that we could define the exact methods that an BaseRetry child class must define.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions