Skip to content

Commit

Permalink
Changing prop to ContextPool, returning pool instead of entire builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeyertons committed Oct 16, 2023
1 parent 2954abd commit a4899d7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Polly.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#nullable enable
Polly.ResiliencePipelineBuilderBase.ResilienceContextPool.get -> Polly.ResilienceContextPool?
Polly.ResiliencePipelineBuilderBase.ResilienceContextPool.set -> void
Polly.ResiliencePipelineBuilderBase.ContextPool.get -> Polly.ResilienceContextPool?
Polly.ResiliencePipelineBuilderBase.ContextPool.set -> void
6 changes: 3 additions & 3 deletions src/Polly.Core/Registry/RegistryPipelineComponentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public RegistryPipelineComponentBuilder(
_configure = configure;
}

internal (TBuilder builder, PipelineComponent component) CreateComponent()
internal (ResilienceContextPool? contextPool, PipelineComponent component) CreateComponent()
{
var builder = CreateBuilder();
var component = builder.ComponentFactory();

if (builder.ReloadTokens.Count == 0)
{
return (builder.Instance, component);
return (builder.Instance.ContextPool, component);
}

component = PipelineComponentFactory.CreateReloadable(
Expand All @@ -48,7 +48,7 @@ public RegistryPipelineComponentBuilder(
return new ReloadableComponent.Entry(builder.ComponentFactory(), builder.ReloadTokens, builder.Telemetry);
});

return (builder.Instance, component);
return (builder.Instance.ContextPool, component);
}

private Builder CreateBuilder()
Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Core/Registry/ResiliencePipelineRegistry.TResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public ResiliencePipeline<TResult> GetOrAdd(TKey key, Action<ResiliencePipelineB
_instanceNameFormatter?.Invoke(k),
configure);
(var builder, var component) = componentBuilder.CreateComponent();
(var contextPool, var component) = componentBuilder.CreateComponent();
return new ResiliencePipeline<TResult>(component, DisposeBehavior.Reject, builder.ResilienceContextPool);
return new ResiliencePipeline<TResult>(component, DisposeBehavior.Reject, contextPool);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Core/Registry/ResiliencePipelineRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public ResiliencePipeline GetOrAddPipeline(TKey key, Action<ResiliencePipelineBu
configure)
;
(var builder, var component) = componentBuilder.CreateComponent();
(var contextPool, var component) = componentBuilder.CreateComponent();
return new ResiliencePipeline(component, DisposeBehavior.Reject, builder.ResilienceContextPool);
return new ResiliencePipeline(component, DisposeBehavior.Reject, contextPool);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/ResiliencePipelineBuilder.TResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ internal ResiliencePipelineBuilder(ResiliencePipelineBuilderBase other)
/// </summary>
/// <returns>An instance of <see cref="ResiliencePipeline{TResult}"/>.</returns>
/// <exception cref="ValidationException">Thrown when this builder has invalid configuration.</exception>
public ResiliencePipeline<TResult> Build() => new(BuildPipelineComponent(), DisposeBehavior.Allow, ResilienceContextPool);
public ResiliencePipeline<TResult> Build() => new(BuildPipelineComponent(), DisposeBehavior.Allow, ContextPool);
}
2 changes: 1 addition & 1 deletion src/Polly.Core/ResiliencePipelineBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public sealed class ResiliencePipelineBuilder : ResiliencePipelineBuilderBase
/// </summary>
/// <returns>An instance of <see cref="ResiliencePipeline"/>.</returns>
/// <exception cref="ValidationException">Thrown when this builder has invalid configuration.</exception>
public ResiliencePipeline Build() => new(BuildPipelineComponent(), DisposeBehavior.Allow, ResilienceContextPool);
public ResiliencePipeline Build() => new(BuildPipelineComponent(), DisposeBehavior.Allow, ContextPool);
}
2 changes: 1 addition & 1 deletion src/Polly.Core/ResiliencePipelineBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private protected ResiliencePipelineBuilderBase(ResiliencePipelineBuilderBase ot
/// <value>
/// If the default value of <see langword="null"/> is used, <see cref="ResilienceContextPool.Shared"/> will be used.
/// </value>
public ResilienceContextPool? ResilienceContextPool { get; set; }
public ResilienceContextPool? ContextPool { get; set; }

/// <summary>
/// Gets or sets a <see cref="System.TimeProvider"/> that is used by strategies that work with time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public async Task DynamicContextPool_1687()

services.AddResiliencePipelineRegistry<string>(options => options.BuilderFactory = () => new ResiliencePipelineBuilder
{
ResilienceContextPool = pool,
ContextPool = pool,
});

services.AddResiliencePipeline(key, builder =>
{
builder.ResilienceContextPool.Should().Be(pool);
builder.ContextPool.Should().Be(pool);
builder.AddStrategy(strategy);
});

Expand Down

0 comments on commit a4899d7

Please sign in to comment.