Skip to content

Commit

Permalink
Drop unused ResiliencePipelineREgistri APIs (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
martintmk authored Aug 17, 2023
1 parent 57c540d commit 46dc47f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 249 deletions.
8 changes: 0 additions & 8 deletions src/Polly.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,14 @@ Polly.Registry.ConfigureBuilderContext<TKey>.PipelineKey.get -> TKey
Polly.Registry.ResiliencePipelineProvider<TKey>
Polly.Registry.ResiliencePipelineProvider<TKey>.ResiliencePipelineProvider() -> void
Polly.Registry.ResiliencePipelineRegistry<TKey>
Polly.Registry.ResiliencePipelineRegistry<TKey>.ClearPipelines() -> void
Polly.Registry.ResiliencePipelineRegistry<TKey>.ClearPipelines<TResult>() -> void
Polly.Registry.ResiliencePipelineRegistry<TKey>.GetOrAddPipeline(TKey key, System.Action<Polly.ResiliencePipelineBuilder!, Polly.Registry.ConfigureBuilderContext<TKey>!>! configure) -> Polly.ResiliencePipeline!
Polly.Registry.ResiliencePipelineRegistry<TKey>.GetOrAddPipeline(TKey key, System.Action<Polly.ResiliencePipelineBuilder!>! configure) -> Polly.ResiliencePipeline!
Polly.Registry.ResiliencePipelineRegistry<TKey>.GetOrAddPipeline<TResult>(TKey key, System.Action<Polly.ResiliencePipelineBuilder<TResult>!, Polly.Registry.ConfigureBuilderContext<TKey>!>! configure) -> Polly.ResiliencePipeline<TResult>!
Polly.Registry.ResiliencePipelineRegistry<TKey>.GetOrAddPipeline<TResult>(TKey key, System.Action<Polly.ResiliencePipelineBuilder<TResult>!>! configure) -> Polly.ResiliencePipeline<TResult>!
Polly.Registry.ResiliencePipelineRegistry<TKey>.RemoveBuilder(TKey key) -> bool
Polly.Registry.ResiliencePipelineRegistry<TKey>.RemoveBuilder<TResult>(TKey key) -> bool
Polly.Registry.ResiliencePipelineRegistry<TKey>.RemovePipeline(TKey key) -> bool
Polly.Registry.ResiliencePipelineRegistry<TKey>.RemovePipeline<TResult>(TKey key) -> bool
Polly.Registry.ResiliencePipelineRegistry<TKey>.ResiliencePipelineRegistry() -> void
Polly.Registry.ResiliencePipelineRegistry<TKey>.ResiliencePipelineRegistry(Polly.Registry.ResiliencePipelineRegistryOptions<TKey>! options) -> void
Polly.Registry.ResiliencePipelineRegistry<TKey>.TryAddBuilder(TKey key, System.Action<Polly.ResiliencePipelineBuilder!, Polly.Registry.ConfigureBuilderContext<TKey>!>! configure) -> bool
Polly.Registry.ResiliencePipelineRegistry<TKey>.TryAddBuilder<TResult>(TKey key, System.Action<Polly.ResiliencePipelineBuilder<TResult>!, Polly.Registry.ConfigureBuilderContext<TKey>!>! configure) -> bool
Polly.Registry.ResiliencePipelineRegistry<TKey>.TryAddPipeline(TKey key, Polly.ResiliencePipeline! pipeline) -> bool
Polly.Registry.ResiliencePipelineRegistry<TKey>.TryAddPipeline<TResult>(TKey key, Polly.ResiliencePipeline<TResult>! pipeline) -> bool
Polly.Registry.ResiliencePipelineRegistryOptions<TKey>
Polly.Registry.ResiliencePipelineRegistryOptions<TKey>.BuilderComparer.get -> System.Collections.Generic.IEqualityComparer<TKey>!
Polly.Registry.ResiliencePipelineRegistryOptions<TKey>.BuilderComparer.set -> void
Expand Down
8 changes: 0 additions & 8 deletions src/Polly.Core/Registry/ResiliencePipelineRegistry.TResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public GenericRegistry(
_instanceNameFormatter = instanceNameFormatter;
}

public bool TryAdd(TKey key, ResiliencePipeline<TResult> strategy) => _strategies.TryAdd(key, strategy);

public bool Remove(TKey key) => _strategies.TryRemove(key, out _);

public bool TryGet(TKey key, [NotNullWhen(true)] out ResiliencePipeline<TResult>? strategy)
{
if (_strategies.TryGetValue(key, out strategy))
Expand Down Expand Up @@ -65,9 +61,5 @@ public ResiliencePipeline<TResult> GetOrAdd(TKey key, Action<ResiliencePipelineB
}

public bool TryAddBuilder(TKey key, Action<ResiliencePipelineBuilder<TResult>, ConfigureBuilderContext<TKey>> configure) => _builders.TryAdd(key, configure);

public bool RemoveBuilder(TKey key) => _builders.TryRemove(key, out _);

public void Clear() => _strategies.Clear();
}
}
76 changes: 0 additions & 76 deletions src/Polly.Core/Registry/ResiliencePipelineRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,50 +60,6 @@ public ResiliencePipelineRegistry(ResiliencePipelineRegistryOptions<TKey> option
_pipelineComparer = options.PipelineComparer;
}

/// <summary>
/// Tries to add an existing resilience pipeline to the registry.
/// </summary>
/// <param name="key">The key used to identify the resilience pipeline.</param>
/// <param name="pipeline">The resilience pipeline instance.</param>
/// <returns><see langword="true"/> if the pipeline was added successfully, <see langword="false"/> otherwise.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="pipeline"/> is <see langword="null"/>.</exception>
public bool TryAddPipeline(TKey key, ResiliencePipeline pipeline)
{
Guard.NotNull(pipeline);

return _pipelines.TryAdd(key, pipeline);
}

/// <summary>
/// Tries to add an existing generic resilience pipeline to the registry.
/// </summary>
/// <typeparam name="TResult">The type of result that the resilience pipeline handles.</typeparam>
/// <param name="key">The key used to identify the resilience pipeline.</param>
/// <param name="pipeline">The resilience pipeline instance.</param>
/// <returns><see langword="true"/> if the pipeline was added successfully, <see langword="false"/> otherwise.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="pipeline"/> is <see langword="null"/>.</exception>
public bool TryAddPipeline<TResult>(TKey key, ResiliencePipeline<TResult> pipeline)
{
Guard.NotNull(pipeline);

return GetGenericRegistry<TResult>().TryAdd(key, pipeline);
}

/// <summary>
/// Removes a resilience pipeline from the registry.
/// </summary>
/// <param name="key">The key used to identify the resilience pipeline.</param>
/// <returns><see langword="true"/> if the pipeline was removed successfully, <see langword="false"/> otherwise.</returns>
public bool RemovePipeline(TKey key) => _pipelines.TryRemove(key, out _);

/// <summary>
/// Removes a generic resilience pipeline from the registry.
/// </summary>
/// <typeparam name="TResult">The type of result that the resilience pipeline handles.</typeparam>
/// <param name="key">The key used to identify the resilience pipeline.</param>
/// <returns><see langword="true"/> if the pipeline was removed successfully, <see langword="false"/> otherwise.</returns>
public bool RemovePipeline<TResult>(TKey key) => GetGenericRegistry<TResult>().Remove(key);

/// <inheritdoc/>
public override bool TryGetPipeline<TResult>(TKey key, [NotNullWhen(true)] out ResiliencePipeline<TResult>? pipeline)
{
Expand Down Expand Up @@ -232,38 +188,6 @@ public bool TryAddBuilder<TResult>(TKey key, Action<ResiliencePipelineBuilder<TR
return GetGenericRegistry<TResult>().TryAddBuilder(key, configure);
}

/// <summary>
/// Removes a resilience pipeline builder from the registry.
/// </summary>
/// <param name="key">The key used to identify the resilience pipeline builder.</param>
/// <returns><see langword="true"/> if the builder was removed successfully, <see langword="false"/> otherwise.</returns>
public bool RemoveBuilder(TKey key) => _builders.TryRemove(key, out _);

/// <summary>
/// Removes a generic resilience pipeline builder from the registry.
/// </summary>
/// <typeparam name="TResult">The type of result that the resilience pipeline handles.</typeparam>
/// <param name="key">The key used to identify the resilience pipeline builder.</param>
/// <returns><see langword="true"/> if the builder was removed successfully, <see langword="false"/> otherwise.</returns>
public bool RemoveBuilder<TResult>(TKey key) => GetGenericRegistry<TResult>().RemoveBuilder(key);

/// <summary>
/// Clears all cached pipelines.
/// </summary>
/// <remarks>
/// This method only clears the cached pipelines, the registered builders are kept unchanged.
/// </remarks>
public void ClearPipelines() => _pipelines.Clear();

/// <summary>
/// Clears all cached generic pipelines.
/// </summary>
/// <typeparam name="TResult">The type of result that the resilience pipeline handles.</typeparam>
/// <remarks>
/// This method only clears the cached pipelines, the registered builders are kept unchanged.
/// </remarks>
public void ClearPipelines<TResult>() => GetGenericRegistry<TResult>().Clear();

private static PipelineComponent CreatePipelineComponent<TBuilder>(
Func<TBuilder> activator,
ConfigureBuilderContext<TKey> context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ public static IServiceCollection AddResiliencePipeline<TKey, TResult>(
{
options.Actions.Add((registry) =>
{
// the last added builder with the same key wins, this allows overriding the builders
registry.RemoveBuilder<TResult>(key);
registry.TryAddBuilder<TResult>(key, (builder, context) =>
{
configure(builder, new AddResiliencePipelineContext<TKey>(context, serviceProvider));
Expand Down Expand Up @@ -148,7 +146,6 @@ public static IServiceCollection AddResiliencePipeline<TKey>(
options.Actions.Add((registry) =>
{
// the last added builder with the same key wins, this allows overriding the builders
registry.RemoveBuilder(key);
registry.TryAddBuilder(key, (builder, context) =>
{
configure(builder, new AddResiliencePipelineContext<TKey>(context, serviceProvider));
Expand Down
Loading

0 comments on commit 46dc47f

Please sign in to comment.