Skip to content

Commit

Permalink
fix(Api): Fixed the CloudEventPublisher to not retry retrieving the c…
Browse files Browse the repository at this point in the history
…loud event stream info

Signed-off-by: Charles d'Avernas <[email protected]>
  • Loading branch information
cdavernas committed Oct 21, 2024
1 parent e8d3f70 commit 1eda1a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/api/Synapse.Api.Application/Services/CloudEventPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,13 @@ public virtual async Task StartAsync(CancellationToken cancellationToken)
var version = ((string)(this.Database.Execute("INFO", "server"))!).Split('\n').FirstOrDefault(line => line.StartsWith("redis_version:"))?[14..]?.Trim() ?? "undetermined";
try
{
while (true)
try
{
try
{
await this.Database.StreamInfoAsync(SynapseDefaults.CloudEvents.Bus.StreamName).ConfigureAwait(false);
break;
}
catch (RedisServerException ex) when (ex.Message.StartsWith("ERR no such key"))
{
await Task.Delay(25, cancellationToken).ConfigureAwait(false);
continue;
}
await this.Database.StreamInfoAsync(SynapseDefaults.CloudEvents.Bus.StreamName).ConfigureAwait(false);
}
catch (RedisServerException ex) when (ex.Message.StartsWith("ERR no such key"))
{
this.Logger.LogWarning("The cloud event stream is currently unavailable, but it should be created when cloud events are published or when correlators are activated");
}
this.SupportsStreaming = true;
this.Logger.LogInformation("Redis server version '{version}' supports streaming commands. Streaming feature is enabled", version);
Expand All @@ -112,6 +107,10 @@ public virtual async Task StartAsync(CancellationToken cancellationToken)
this.SupportsStreaming = false;
this.Logger.LogInformation("Redis server version '{version}' does not support streaming commands. Streaming feature is emulated using lists", version);
}
catch(Exception ex)
{
this.Logger.LogWarning("An error occurred while starting the cloud event publisher, possibly affecting the server's ability to publish cloud events to correlators: {ex}", ex);
}
}

/// <inheritdoc/>
Expand Down
2 changes: 2 additions & 0 deletions src/core/Synapse.Core/Synapse.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<ItemGroup>
<None Remove="Resources\Correlation.yaml" />
<None Remove="Resources\Correlator.yaml" />
<None Remove="Resources\CustomFunction.yaml" />
<None Remove="Resources\Operator.yaml" />
<None Remove="Resources\ServiceAccount.yaml" />
<None Remove="Resources\Workflow.yaml" />
Expand All @@ -54,6 +55,7 @@

<ItemGroup>
<EmbeddedResource Include="Resources\Correlation.yaml" />
<EmbeddedResource Include="Resources\CustomFunction.yaml" />
<EmbeddedResource Include="Resources\ServiceAccount.yaml" />
<EmbeddedResource Include="Resources\Correlator.yaml" />
<EmbeddedResource Include="Resources\Operator.yaml" />
Expand Down

0 comments on commit 1eda1a4

Please sign in to comment.