From b232248b32bc636219d2424afe1ea50db176ec92 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Fri, 17 Jan 2025 15:58:54 +0100 Subject: [PATCH 1/4] feat(Runner): Implement event read mode Signed-off-by: Charles d'Avernas --- .../Services/Executors/ListenTaskExecutor.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/runner/Synapse.Runner/Services/Executors/ListenTaskExecutor.cs b/src/runner/Synapse.Runner/Services/Executors/ListenTaskExecutor.cs index 5c6f617f..90231273 100644 --- a/src/runner/Synapse.Runner/Services/Executors/ListenTaskExecutor.cs +++ b/src/runner/Synapse.Runner/Services/Executors/ListenTaskExecutor.cs @@ -62,7 +62,13 @@ protected override async Task DoExecuteAsync(CancellationToken cancellationToken if (this.Task.Definition.Foreach == null) { var context = await this.Task.CorrelateAsync(cancellationToken).ConfigureAwait(false); - await this.SetResultAsync(context, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false); + var events = this.Task.Definition.Listen.Read switch + { + EventReadMode.Data or EventReadMode.Raw => context.Events.Select(e => e.Value.Data), + EventReadMode.Envelope => context.Events.Select(e => e.Value.Data), + _ => throw new NotSupportedException($"The specified event read mode '{this.Task.Definition.Listen.Read}' is not supported") + }; + await this.SetResultAsync(events, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false); } else { @@ -107,7 +113,12 @@ protected virtual async Task OnStreamingEventAsync(IStreamedCloudEvent e) ] }; var arguments = this.GetExpressionEvaluationArguments(); - var eventData = e.Event as object; + var eventData = this.Task.Definition.Listen.Read switch + { + EventReadMode.Data or EventReadMode.Raw => e.Event.Data, + EventReadMode.Envelope => e.Event, + _ => throw new NotSupportedException($"The specified event read mode '{this.Task.Definition.Listen.Read}' is not supported") + }; if (this.Task.Definition.Foreach.Output?.As is string fromExpression) eventData = await this.Task.Workflow.Expressions.EvaluateAsync(fromExpression, eventData ?? new(), arguments, this.CancellationTokenSource!.Token).ConfigureAwait(false); else if (this.Task.Definition.Foreach.Output?.As != null) eventData = await this.Task.Workflow.Expressions.EvaluateAsync(this.Task.Definition.Foreach.Output.As!, eventData ?? new(), arguments, this.CancellationTokenSource!.Token).ConfigureAwait(false); if (this.Task.Definition.Foreach.Export?.As is string toExpression) From 34d20f3f45e2391985d91610332b5ee821e1904d Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 22 Jan 2025 13:34:56 +0100 Subject: [PATCH 2/4] fix(Dashboard): Fixed the workflow schema validation, which was using obsolete URIs to get the schema files Signed-off-by: Charles d'Avernas --- src/dashboard/Synapse.Dashboard/Pages/Functions/Create/Store.cs | 2 +- .../Synapse.Dashboard/Services/SpecificationSchemaManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/Store.cs b/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/Store.cs index 254d13ff..273ec61b 100644 --- a/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/Store.cs +++ b/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/Store.cs @@ -565,7 +565,7 @@ protected async Task SetValidationSchema(string? version = null) this._processingVersion = true; try { - var schema = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/static/schemas/{version}/workflow.yaml#/$defs/task"; + var schema = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/public/schemas/{version}/workflow.yaml#/$defs/task"; var type = $"create_{typeof(CustomFunction).Name.ToLower()}_{version}_schema"; await this.MonacoInterop.AddValidationSchemaAsync(schema, $"https://synapse.io/schemas/{type}.json", $"{type}*").ConfigureAwait(false); this._textModelUri = this.MonacoEditorHelper.GetResourceUri(type); diff --git a/src/dashboard/Synapse.Dashboard/Services/SpecificationSchemaManager.cs b/src/dashboard/Synapse.Dashboard/Services/SpecificationSchemaManager.cs index f14267c8..928132ee 100644 --- a/src/dashboard/Synapse.Dashboard/Services/SpecificationSchemaManager.cs +++ b/src/dashboard/Synapse.Dashboard/Services/SpecificationSchemaManager.cs @@ -57,7 +57,7 @@ public async Task GetLatestVersion() public async Task GetSchema(string version) { if (_knownSchemas.TryGetValue(version, out string? value)) return value; - var address = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/static/schemas/{version}/workflow.yaml"; + var address = $"https://raw.githubusercontent.com/serverlessworkflow/serverlessworkflow.github.io/main/public/schemas/{version}/workflow.yaml"; var yamlSchema = await this.HttpClient.GetStringAsync(address); this._knownSchemas.Add(version, this.YamlSerializer.ConvertToJson(yamlSchema)); return this._knownSchemas[version]; From 45c22a1a8ac26346fcef62f441482c1e8c887fb5 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 22 Jan 2025 15:03:10 +0100 Subject: [PATCH 3/4] fix(Runner): Fixed the `TaskExecutor` to ignore both `output.as` and `export.as` clauses for skipped tasks Fixes #481 Signed-off-by: Charles d'Avernas --- src/runner/Synapse.Runner/Services/TaskExecutor.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/runner/Synapse.Runner/Services/TaskExecutor.cs b/src/runner/Synapse.Runner/Services/TaskExecutor.cs index 78c7687c..e655edc6 100644 --- a/src/runner/Synapse.Runner/Services/TaskExecutor.cs +++ b/src/runner/Synapse.Runner/Services/TaskExecutor.cs @@ -379,20 +379,6 @@ public virtual async Task SkipAsync(object? result, string? then = FlowDirective this.Stopwatch.Stop(); if (string.IsNullOrWhiteSpace(then)) then = FlowDirective.Continue; var output = result; - var arguments = this.GetExpressionEvaluationArguments() ?? new Dictionary(); - arguments[RuntimeExpressions.Arguments.Output] = output!; - if (this.Task.Definition.Output?.As is string fromExpression) output = await this.Task.Workflow.Expressions.EvaluateAsync(fromExpression, output ?? new(), arguments, cancellationToken).ConfigureAwait(false); - else if (this.Task.Definition.Output?.As != null) output = await this.Task.Workflow.Expressions.EvaluateAsync(this.Task.Definition.Output.As, output ?? new(), arguments, cancellationToken).ConfigureAwait(false); - if (this.Task.Definition.Export?.As is string toExpression) - { - var context = (await this.Task.Workflow.Expressions.EvaluateAsync>(toExpression, this.Task.ContextData, arguments, cancellationToken).ConfigureAwait(false))!; - await this.Task.SetContextDataAsync(context, cancellationToken).ConfigureAwait(false); - } - else if (this.Task.Definition.Export?.As != null) - { - var context = (await this.Task.Workflow.Expressions.EvaluateAsync>(this.Task.Definition.Export.As, this.Task.ContextData, this.GetExpressionEvaluationArguments(), cancellationToken).ConfigureAwait(false))!; - await this.Task.SetContextDataAsync(context, cancellationToken).ConfigureAwait(false); - } await this.Task.SkipAsync(output, then, cancellationToken).ConfigureAwait(false); this.Subject.OnNext(new TaskLifeCycleEvent(TaskLifeCycleEventType.Skipped)); this.Subject.OnCompleted(); From f23a7574ae7f24253560d20a977b3ba448e6e843 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 22 Jan 2025 15:05:33 +0100 Subject: [PATCH 4/4] fix(Solution): Updated projects version to `1.0.0-alpha5.11` Signed-off-by: Charles d'Avernas --- src/api/Synapse.Api.Application/Synapse.Api.Application.csproj | 2 +- src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj | 2 +- src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj | 2 +- src/api/Synapse.Api.Http/Synapse.Api.Http.csproj | 2 +- src/api/Synapse.Api.Server/Synapse.Api.Server.csproj | 2 +- src/cli/Synapse.Cli/Synapse.Cli.csproj | 2 +- .../Synapse.Core.Infrastructure.Containers.Docker.csproj | 2 +- .../Synapse.Core.Infrastructure.Containers.Kubernetes.csproj | 2 +- .../Synapse.Core.Infrastructure.csproj | 2 +- src/core/Synapse.Core/Synapse.Core.csproj | 2 +- src/correlator/Synapse.Correlator/Synapse.Correlator.csproj | 2 +- src/operator/Synapse.Operator/Synapse.Operator.csproj | 2 +- src/runner/Synapse.Runner/Synapse.Runner.csproj | 2 +- .../Synapse.Runtime.Abstractions.csproj | 2 +- .../Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj | 2 +- .../Synapse.Runtime.Kubernetes.csproj | 2 +- .../Synapse.Runtime.Native/Synapse.Runtime.Native.csproj | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj b/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj index 5a56b155..c817e12b 100644 --- a/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj +++ b/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj b/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj index 038a3046..245da389 100644 --- a/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj +++ b/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj b/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj index b0083eb2..6351a39b 100644 --- a/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj +++ b/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj b/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj index 06d31262..ecfca4e5 100644 --- a/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj +++ b/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj @@ -8,7 +8,7 @@ Library True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj b/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj index 093aad1a..4dba39d6 100644 --- a/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj +++ b/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/cli/Synapse.Cli/Synapse.Cli.csproj b/src/cli/Synapse.Cli/Synapse.Cli.csproj index 70079e45..e1f97ab7 100644 --- a/src/cli/Synapse.Cli/Synapse.Cli.csproj +++ b/src/cli/Synapse.Cli/Synapse.Cli.csproj @@ -8,7 +8,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj b/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj index b39a6548..a275615a 100644 --- a/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj +++ b/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj b/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj index 4d5fa673..130724dd 100644 --- a/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj +++ b/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj b/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj index a2ee6abe..29b76edb 100644 --- a/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj +++ b/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/core/Synapse.Core/Synapse.Core.csproj b/src/core/Synapse.Core/Synapse.Core.csproj index 76c0e3b6..c256c332 100644 --- a/src/core/Synapse.Core/Synapse.Core.csproj +++ b/src/core/Synapse.Core/Synapse.Core.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj b/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj index af3a358d..6fc97f54 100644 --- a/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj +++ b/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj @@ -8,7 +8,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/operator/Synapse.Operator/Synapse.Operator.csproj b/src/operator/Synapse.Operator/Synapse.Operator.csproj index e11fe155..93d7712e 100644 --- a/src/operator/Synapse.Operator/Synapse.Operator.csproj +++ b/src/operator/Synapse.Operator/Synapse.Operator.csproj @@ -8,7 +8,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/runner/Synapse.Runner/Synapse.Runner.csproj b/src/runner/Synapse.Runner/Synapse.Runner.csproj index 31b8025a..dc1e6fe0 100644 --- a/src/runner/Synapse.Runner/Synapse.Runner.csproj +++ b/src/runner/Synapse.Runner/Synapse.Runner.csproj @@ -8,7 +8,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj b/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj index 2494eadc..8d479961 100644 --- a/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj +++ b/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj b/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj index ec2a3dab..72020a79 100644 --- a/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj +++ b/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj b/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj index 60e3a089..da1d7839 100644 --- a/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj +++ b/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors diff --git a/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj b/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj index a35678e1..a97a7d6d 100644 --- a/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj +++ b/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj @@ -7,7 +7,7 @@ en True 1.0.0 - alpha5.8 + alpha5.11 $(VersionPrefix) $(VersionPrefix) The Synapse Authors