Skip to content

Commit 1eda1a4

Browse files
committed
fix(Api): Fixed the CloudEventPublisher to not retry retrieving the cloud event stream info
Signed-off-by: Charles d'Avernas <[email protected]>
1 parent e8d3f70 commit 1eda1a4

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/api/Synapse.Api.Application/Services/CloudEventPublisher.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,13 @@ public virtual async Task StartAsync(CancellationToken cancellationToken)
9191
var version = ((string)(this.Database.Execute("INFO", "server"))!).Split('\n').FirstOrDefault(line => line.StartsWith("redis_version:"))?[14..]?.Trim() ?? "undetermined";
9292
try
9393
{
94-
while (true)
94+
try
9595
{
96-
try
97-
{
98-
await this.Database.StreamInfoAsync(SynapseDefaults.CloudEvents.Bus.StreamName).ConfigureAwait(false);
99-
break;
100-
}
101-
catch (RedisServerException ex) when (ex.Message.StartsWith("ERR no such key"))
102-
{
103-
await Task.Delay(25, cancellationToken).ConfigureAwait(false);
104-
continue;
105-
}
96+
await this.Database.StreamInfoAsync(SynapseDefaults.CloudEvents.Bus.StreamName).ConfigureAwait(false);
97+
}
98+
catch (RedisServerException ex) when (ex.Message.StartsWith("ERR no such key"))
99+
{
100+
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");
106101
}
107102
this.SupportsStreaming = true;
108103
this.Logger.LogInformation("Redis server version '{version}' supports streaming commands. Streaming feature is enabled", version);
@@ -112,6 +107,10 @@ public virtual async Task StartAsync(CancellationToken cancellationToken)
112107
this.SupportsStreaming = false;
113108
this.Logger.LogInformation("Redis server version '{version}' does not support streaming commands. Streaming feature is emulated using lists", version);
114109
}
110+
catch(Exception ex)
111+
{
112+
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);
113+
}
115114
}
116115

117116
/// <inheritdoc/>

src/core/Synapse.Core/Synapse.Core.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<ItemGroup>
4747
<None Remove="Resources\Correlation.yaml" />
4848
<None Remove="Resources\Correlator.yaml" />
49+
<None Remove="Resources\CustomFunction.yaml" />
4950
<None Remove="Resources\Operator.yaml" />
5051
<None Remove="Resources\ServiceAccount.yaml" />
5152
<None Remove="Resources\Workflow.yaml" />
@@ -54,6 +55,7 @@
5455

5556
<ItemGroup>
5657
<EmbeddedResource Include="Resources\Correlation.yaml" />
58+
<EmbeddedResource Include="Resources\CustomFunction.yaml" />
5759
<EmbeddedResource Include="Resources\ServiceAccount.yaml" />
5860
<EmbeddedResource Include="Resources\Correlator.yaml" />
5961
<EmbeddedResource Include="Resources\Operator.yaml" />

0 commit comments

Comments
 (0)