feat(extensions): add EnableReloads overload accepting custom IOptionsMonitor#3140
Conversation
…sMonitor Closes App-vNext#3050 Adds a new public overload of AddResiliencePipelineContext<TKey>.EnableReloads<TOptions> that accepts a caller-supplied IOptionsMonitor<TOptions> directly, instead of resolving it from the DI container. The underlying ConfigureBuilderContextExtensions.EnableReloads already accepts the monitor directly - this change surfaces that path through the public API. Use cases enabled: - Custom options systems outside Microsoft.Extensions.Options - Wrapping alternative configuration sources (feature flags, remote configs) - Sharing monitor instances across pipelines without DI registration
| using Polly.Registry; | ||
| using Polly.Utils; | ||
|
|
||
| #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters |
There was a problem hiding this comment.
Please rework the API to remove the need to suppress this warning.
There was a problem hiding this comment.
Reworked the API to avoid the RS0026 suppression entirely. The new IOptionsMonitor overload no longer has an optional name parameter — instead there are two explicit overloads: one with just the monitor, and one with both monitor and name. The original EnableReloads<TOptions>(string? name = null) remains unchanged (no breaking change). The RS0027 that appears on the original overload (a consequence of adding a 2-param sibling) is suppressed with a targeted pragma/restore pair on that method only, consistent with the pattern already used in Polly.Core.
| #nullable enable | ||
| abstract Polly.Telemetry.MeteringEnricher.Enrich<TResult, TArgs>(in Polly.Telemetry.EnrichmentContext<TResult, TArgs> context) -> void | ||
| Polly.DependencyInjection.AddResiliencePipelineContext<TKey> | ||
| Polly.DependencyInjection.AddResiliencePipelineContext<TKey>.EnableReloads<TOptions>(string? name = null) -> void |
There was a problem hiding this comment.
This is a breaking change.
…suppressions Replace the file-level RS0026 suppression with an API design that needs no suppression: - Keep the shipped EnableReloads<TOptions>(string? name = null) overload unchanged - Add EnableReloads<TOptions>(IOptionsMonitor<TOptions> monitor) (no-name convenience) - Add EnableReloads<TOptions>(IOptionsMonitor<TOptions> monitor, string? name) without optional parameter, eliminating the RS0026 violation - Add a targeted RS0027 suppress/restore around the original overload only, consistent with the pattern used in Polly.Core for the same constraint
c52d8f8 to
a260473
Compare
closes #3050
Adds a new public overload of AddResiliencePipelineContext.EnableReloads that accepts a caller-supplied IOptionsMonitor directly, instead of resolving it from the DI container.
The underlying ConfigureBuilderContextExtensions.EnableReloads already accepts the monitor directly - this change surfaces that path through the public API.
Use cases enabled:
Confirm the following