Skip to content

[Feature request]: Expose EnableReloads overload that accepts a custom IOptionsMonitor<TOptions> instance #3050

@denisbredikhin

Description

@denisbredikhin

Is your feature request related to a specific problem? Or an existing feature?

Currently, AddResiliencePipelineContext.EnableReloads<TOptions>() only supports enabling reloads via an IOptionsMonitor<TOptions> that is resolved from DI:

RegistryContext.EnableReloads(
    ServiceProvider.GetRequiredService<IOptionsMonitor<TOptions>>(),
    name);

This makes it impossible to enable reloads for custom or external IOptionsMonitor<TOptions> implementations that are not registered in DI as IOptionsMonitor<TOptions>.

This limitation prevents several legitimate and advanced scenarios, such as:

  • Using a custom options system not based on Microsoft.Extensions.Options
  • Wrapping another configuration source (feature flags, remote config, tenant-specific config, etc.)
  • Sharing a single monitor instance across multiple pipelines without DI registration
  • Avoiding DI pollution when the monitor is internal or pipeline-specific

Describe the solution you'd like

Expose an additional public overload that allows explicitly supplying an IOptionsMonitor<TOptions> instance:

public void EnableReloads<TOptions>(
    IOptionsMonitor<TOptions> monitor,
    string? name = null)
    where TOptions : class;

This would internally forward to the existing infrastructure currently wired via RegistryContext.EnableReloads(...).

Expected behavior:

  • The pipeline is rebuilt when monitor.OnChange fires
  • name continues to behave the same way as in the existing overload
  • No change in behavior for existing users

This overload would be purely additive and backward-compatible.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions