Skip to content

Add Configurable Retry Parameters #288

@matthew-collett

Description

@matthew-collett

Currently, the client supports retry with WithRetry(true), but retry behavior (attempts, delays, backoff strategy) is not configurable.

Add options to configure retry parameters:

  • Maximum retry attempts
  • Initial retry delay
  • Backoff strategy (exponential, linear, fixed)
  • Maximum retry delay

Proposed API

client := spotify.New(auth.Client(ctx, token), 
    spotify.WithRetry(true),
    spotify.WithMaxRetries(3),
    spotify.WithInitialDelay(time.Second),
    spotify.WithMaxDelay(30*time.Second),
    spotify.WithBackoffStrategy(spotify.ExponentialBackoff),
)
// OR
retryCfg := &spotify.RetryConfig{
    MaxRetries:   3,
    InitialDelay: time.Second,
    MaxDelay:     30 * time.Second,
    Backoff:      spotify.ExponentialBackoff,
}

client := spotify.New(auth.Client(ctx, token), 
    spotify.WithRetry(true),
    spotify.WithRetryConfig(retryCfg),
)

Applications with different reliability requirements need control over retry behaviour to balance between request success rate and response latency.

I would be happy to contribute and work on this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions