armeria icon indicating copy to clipboard operation
armeria copied to clipboard

Enable creating a `RetryConfigMapping` on a per method, path, or host basis

Open schiemon opened this issue 7 months ago • 1 comments

Motivation

If a user wants to construct a caching RetryConfigMapping, they can currently do so by:

  1. Subclassing RetryConfigMapping, or
  2. Using
    RetryConfigMapping.of(
        BiFunction<? super ClientRequestContext, Request, String> keyFactory, 
        BiFunction<? super ClientRequestContext, Request, RetryConfig> mapping
    )
    
    

It is quite common for users of a RetryClient or RpcRetryClient to configure retry behavior on a per-method, per-path, or per-host basis. However, the current options force users who want their configs to be cached to either:

  1. Create their own abstraction to support per-* configuration + caching, or
  2. Use RetryConfigMapping.of where they need to provide a keyFactory which extracts the method, host or path.

This contrasts with the configuration of circuit breaking, where CircuitBreakerMapping provides dedicated methods like .perMethod(), .perHost(), and .perPath() for this purpose.

Solution

In this issue we smooth out RetryConfigMapping to offer the same API as CircuitBreakerMapping, to improve developer experience and ensure consistency between the two configuration mechanisms.

schiemon avatar May 17 '25 09:05 schiemon

I am currently working on this so this issue can be assigned to me 👍

schiemon avatar May 17 '25 11:05 schiemon