Skip to content

Support per-key minDelay and warmupDelay when using key functions #9

@bhope

Description

@bhope

When WithHTTPKeyFunc or WithGRPCKeyFunc is configured to bucket by endpoint (e.g. by path or gRPC method), minDelay and warmupDelay remain global across all keys.

This creates a mismatch for services with heterogeneous endpoint latencies. For example, if /api/fast has a p90 of 2ms and /api/slow has a p90 of 800ms, a global warmupDelay=10ms is appropriate for the former but causes near-constant hedging during warmup for the latter.

Proposed solution (open for discussion)

Option 1: allow the key function to return structured config alongside the key:

WithHTTPKeyFunc(func(r *http.Request) (key string, overrides ...Option) { ... })

Option 2: a separate WithPerKeyDefaults map or a second option that accepts a function func(key string) []Option.

Context

Raised by @qualidafial in #4. Deliberately deferred from that PR to keep scope focused on the key function feature itself.

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