diff --git a/src/OpenFeature/Api.cs b/src/OpenFeature/Api.cs
index d80590a2..6f13cac2 100644
--- a/src/OpenFeature/Api.cs
+++ b/src/OpenFeature/Api.cs
@@ -42,11 +42,10 @@ private Api() { }
///
/// The provider cannot be set to null. Attempting to set the provider to null has no effect.
/// Implementation of
- /// The to cancel any async side effects.
- public async Task SetProviderAsync(FeatureProvider featureProvider, CancellationToken cancellationToken = default)
+ public async Task SetProviderAsync(FeatureProvider featureProvider)
{
this._eventExecutor.RegisterDefaultFeatureProvider(featureProvider);
- await this._repository.SetProviderAsync(featureProvider, this.GetContext(), cancellationToken: cancellationToken).ConfigureAwait(false);
+ await this._repository.SetProviderAsync(featureProvider, this.GetContext()).ConfigureAwait(false);
}
@@ -56,15 +55,14 @@ public async Task SetProviderAsync(FeatureProvider featureProvider, Cancellation
///
/// Name of client
/// Implementation of
- /// The to cancel any async side effects.
- public async Task SetProviderAsync(string clientName, FeatureProvider featureProvider, CancellationToken cancellationToken = default)
+ public async Task SetProviderAsync(string clientName, FeatureProvider featureProvider)
{
if (string.IsNullOrWhiteSpace(clientName))
{
throw new ArgumentNullException(nameof(clientName));
}
this._eventExecutor.RegisterClientFeatureProvider(clientName, featureProvider);
- await this._repository.SetProviderAsync(clientName, featureProvider, this.GetContext(), cancellationToken: cancellationToken).ConfigureAwait(false);
+ await this._repository.SetProviderAsync(clientName, featureProvider, this.GetContext()).ConfigureAwait(false);
}
///
@@ -227,17 +225,18 @@ public EvaluationContext GetContext()
/// Once shut down is complete, API is reset and ready to use again.
///
///
- /// The to cancel any async side effects.
- public async Task ShutdownAsync(CancellationToken cancellationToken = default)
+ public async Task ShutdownAsync()
{
- await this._repository.ShutdownAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
- await this._eventExecutor.ShutdownAsync(cancellationToken).ConfigureAwait(false);
- this._evaluationContext = EvaluationContext.Empty;
- this._hooks.Clear();
+ await using (this._eventExecutor.ConfigureAwait(false))
+ await using (this._repository.ConfigureAwait(false))
+ {
+ this._evaluationContext = EvaluationContext.Empty;
+ this._hooks.Clear();
- // TODO: make these lazy to avoid extra allocations on the common cleanup path?
- this._eventExecutor = new EventExecutor();
- this._repository = new ProviderRepository();
+ // TODO: make these lazy to avoid extra allocations on the common cleanup path?
+ this._eventExecutor = new EventExecutor();
+ this._repository = new ProviderRepository();
+ }
}
///
diff --git a/src/OpenFeature/EventExecutor.cs b/src/OpenFeature/EventExecutor.cs
index 47c30f66..886a47b6 100644
--- a/src/OpenFeature/EventExecutor.cs
+++ b/src/OpenFeature/EventExecutor.cs
@@ -12,7 +12,7 @@ namespace OpenFeature
{
internal delegate Task ShutdownDelegate(CancellationToken cancellationToken);
- internal sealed partial class EventExecutor
+ internal sealed partial class EventExecutor : IAsyncDisposable
{
private readonly object _lockObj = new object();
public readonly Channel