Skip to content

Commit

Permalink
use WriteAsync to write to channel
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <[email protected]>
  • Loading branch information
bacherfl committed Jan 3, 2024
1 parent 2541880 commit dc27b0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/OpenFeature/EventExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void StartListeningAndShutdownOld(FeatureProviderReference newProvider,
var channel = oldProvider.Provider.GetEventChannel();
if (channel != null)
{
channel.Writer.TryWrite(new ShutdownSignal());
channel.Writer.WriteAsync(new ShutdownSignal());
}
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ private async Task ProcessFeatureProviderEventsAsync(FeatureProviderReference pr
switch (item)
{
case ProviderEventPayload eventPayload:
this.EventChannel.Writer.TryWrite(new Event { Provider = providerRef, EventPayload = eventPayload });
this.EventChannel.Writer.WriteAsync(new Event { Provider = providerRef, EventPayload = eventPayload });

Check failure on line 208 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / e2e-tests

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check failure on line 208 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / unit-tests-linux

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check failure on line 208 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / unit-tests-windows

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check failure on line 208 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / unit-tests-windows

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
break;
case ShutdownSignal _:
providerRef.ShutdownSemaphore.Release();
Expand Down Expand Up @@ -264,7 +264,7 @@ private async Task ProcessEventAsync()
public async Task SignalShutdownAsync()
{
// Enqueue a shutdown signal
this.EventChannel.Writer.TryWrite(new ShutdownSignal());
this.EventChannel.Writer.WriteAsync(new ShutdownSignal());

Check failure on line 267 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / e2e-tests

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check failure on line 267 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / unit-tests-linux

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check failure on line 267 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / unit-tests-windows

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check failure on line 267 in src/OpenFeature/EventExecutor.cs

View workflow job for this annotation

GitHub Actions / unit-tests-windows

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

// Wait for the processing loop to acknowledge the shutdown
await this._shutdownSemaphore.WaitAsync().ConfigureAwait(false);
Expand Down
3 changes: 3 additions & 0 deletions test/OpenFeature.Tests/OpenFeatureEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public async Task API_Level_Event_Handlers_Should_Be_Registered()
eventHandler.Invoke(Arg.Any<ProviderEventPayload>());

Api.Instance.AddHandler(ProviderEventTypes.ProviderReady, eventHandler);
Api.Instance.AddHandler(ProviderEventTypes.ProviderConfigurationChanged, eventHandler);
Api.Instance.AddHandler(ProviderEventTypes.ProviderError, eventHandler);
Api.Instance.AddHandler(ProviderEventTypes.ProviderStale, eventHandler);

var testProvider = new TestProvider();
await Api.Instance.SetProvider(testProvider);
Expand Down
4 changes: 2 additions & 2 deletions test/OpenFeature.Tests/TestImplementations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ public override ProviderStatus GetStatus()
public override Task Initialize(EvaluationContext context)
{
this._status = ProviderStatus.Ready;
this.EventChannel.Writer.TryWrite(new ProviderEventPayload { Type = ProviderEventTypes.ProviderReady, ProviderName = this.GetMetadata().Name });
this.EventChannel.Writer.WriteAsync(new ProviderEventPayload { Type = ProviderEventTypes.ProviderReady, ProviderName = this.GetMetadata().Name });
return base.Initialize(context);
}

internal void SendEvent(ProviderEventTypes eventType)
{
this.EventChannel.Writer.TryWrite(new ProviderEventPayload { Type = eventType, ProviderName = this.GetMetadata().Name });
this.EventChannel.Writer.WriteAsync(new ProviderEventPayload { Type = eventType, ProviderName = this.GetMetadata().Name });
}
}
}

0 comments on commit dc27b0c

Please sign in to comment.