Skip to content

Commit 4eedda0

Browse files
authored
Merge pull request #336 from neuroglia-io/fix-eventing
Fixed production of cloud events
2 parents e8d7e91 + 87d1a3b commit 4eedda0

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/apps/Synapse.Server/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"CloudEvents": {
1616
"Sink": {
17-
"Uri": "https://webhook.site/2e78793f-69a5-4ef6-8fdf-d467a9d6f1c6"
17+
"Uri": "https://webhook.site/70e57ac3-c28c-41cc-9a61-070810da8b3b"
1818
}
1919
}
2020
}

src/apps/Synapse.Worker/Services/Processors/AsyncFunctionProcessor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
102102
if (this.Activity.Status == V1WorkflowActivityStatus.Pending)
103103
{
104104
var input = await this.Context.FilterInputAsync(this.Action, this.Activity.Input.ToObject()!, cancellationToken);
105+
if (!string.IsNullOrWhiteSpace(this.Action.Event!.DataExpression)) input = await this.Context.EvaluateAsync(this.Action.Event!.DataExpression, input, cancellationToken);
106+
else if (this.Action.Event.Data != null) input = await this.Context.EvaluateObjectAsync(this.Action.Event!.Data.ToObject()!, input!, cancellationToken);
105107
var metadata = new Dictionary<string, string>()
106108
{
107109
{ V1WorkflowActivityMetadata.State, this.State.Name },

src/core/Synapse.Application/Extensions/V1EventExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ public static CloudEvent AsCloudEvent(this V1Event e)
4141
ce.DataContentType = e.DataContentType;
4242
ce.DataSchema = e.DataSchema;
4343
ce.Data = e.Data;
44-
foreach(var extension in e.ExtensionAttributes)
44+
if(e.ExtensionAttributes != null)
4545
{
46-
ce.SetAttributeFromString(extension.Key, extension.Value?.ToString()!);
46+
foreach (var extension in e.ExtensionAttributes)
47+
{
48+
ce.SetAttributeFromString(extension.Key, extension.Value?.ToString()!);
49+
}
4750
}
4851
return ce;
4952
}

0 commit comments

Comments
 (0)