Skip to content

Commit c4181aa

Browse files
authored
Merge pull request #470 from serverlessworkflow/feat-stand-alone-runner
Added a new stand-alone execution mode to the runner
2 parents f532e8a + 6d2baf0 commit c4181aa

File tree

37 files changed

+1250
-96
lines changed

37 files changed

+1250
-96
lines changed

src/api/Synapse.Api.Application/Synapse.Api.Application.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Client.Core/Services/IDocumentApiClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ public interface IDocumentApiClient
5151
/// <param name="id">The id of the <see cref="Document"/> to delete</param>
5252
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
5353
/// <returns>The <see cref="Document"/> with the specified id</returns>
54-
Task DeletesAsync(string id, CancellationToken cancellationToken = default);
54+
Task DeleteAsync(string id, CancellationToken cancellationToken = default);
5555

5656
}

src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Client.Http/Services/DocumentHttpApiClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public virtual async Task UpdateAsync(string id, object content, CancellationTok
6868
}
6969

7070
/// <inheritdoc/>
71-
public virtual async Task DeletesAsync(string id, CancellationToken cancellationToken = default)
71+
public virtual async Task DeleteAsync(string id, CancellationToken cancellationToken = default)
7272
{
7373
ArgumentException.ThrowIfNullOrWhiteSpace(id);
7474
var uri = $"{PathPrefix}/{id}";

src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Http/Synapse.Api.Http.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>Library</OutputType>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha5.7</VersionSuffix>
11+
<VersionSuffix>alpha5.8</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Server/Synapse.Api.Server.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/cli/Synapse.Cli/Synapse.Cli.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NeutralLanguage>en</NeutralLanguage>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha5.7</VersionSuffix>
11+
<VersionSuffix>alpha5.8</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha5.7</VersionSuffix>
10+
<VersionSuffix>alpha5.8</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core/SynapseDefaults.cs

+18
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,24 @@ public static class Runner
678678
/// </summary>
679679
public const string Name = Prefix + "NAME";
680680

681+
/// <summary>
682+
/// Exposes constants about environment variables related to runner cloud events
683+
/// </summary>
684+
public static class CloudEvents
685+
{
686+
687+
/// <summary>
688+
/// Gets the prefix for all environment variables related to runner cloud events
689+
/// </summary>
690+
public const string Prefix = Runner.Prefix + "CLOUD_EVENTS_";
691+
692+
/// <summary>
693+
/// Gets the environment variable used to configure the runner's cloud event sink
694+
/// </summary>
695+
public const string Sink = Prefix + "SINK";
696+
697+
}
698+
681699
}
682700

683701
/// <summary>

src/correlator/Synapse.Correlator/Synapse.Correlator.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NeutralLanguage>en</NeutralLanguage>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha5.7</VersionSuffix>
11+
<VersionSuffix>alpha5.8</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/operator/Synapse.Operator/Synapse.Operator.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NeutralLanguage>en</NeutralLanguage>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha5.7</VersionSuffix>
11+
<VersionSuffix>alpha5.8</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/runner/Synapse.Runner/Configuration/RunnerCloudEventOptions.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@ public class RunnerCloudEventOptions
2828
public RunnerCloudEventOptions()
2929
{
3030
var env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.LifecycleEvents);
31-
if(!string.IsNullOrWhiteSpace(env) && bool.TryParse(env, out var publishLifecycleEvents)) this.PublishLifecycleEvents = publishLifecycleEvents;
31+
if (!string.IsNullOrWhiteSpace(env) && bool.TryParse(env, out var publishLifecycleEvents)) this.PublishLifecycleEvents = publishLifecycleEvents;
32+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.CloudEvents.Sink);
33+
if (!string.IsNullOrWhiteSpace(env) && Uri.TryCreate(env, UriKind.RelativeOrAbsolute, out var sink)) this.Sink = sink;
3234
}
3335

3436
/// <summary>
3537
/// Gets/sets a boolean indicating whether or not the Synapse Runner should produce lifecycle events. Defaults to `true`.
3638
/// </summary>
3739
public virtual bool PublishLifecycleEvents { get; set; } = true;
3840

41+
/// <summary>
42+
/// Gets/sets the
43+
/// </summary>
44+
public virtual Uri? Sink { get; set; }
45+
3946
}

src/runner/Synapse.Runner/Configuration/RunnerContainerOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class RunnerContainerOptions
2929
public RunnerContainerOptions()
3030
{
3131
var env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.ContainerPlatform)?.ToLowerInvariant();
32-
if (string.IsNullOrWhiteSpace(env)) throw new NullReferenceException("The runner's container platform must be configured");
32+
if (string.IsNullOrWhiteSpace(env)) env = ContainerPlatform.Docker;
3333
switch (env)
3434
{
3535
case ContainerPlatform.Docker:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
using System.Runtime.Serialization;
15+
16+
namespace Synapse.Runner.Configuration;
17+
18+
/// <summary>
19+
/// Enumerates all modes of execution for the Synapse Runner application
20+
/// </summary>
21+
public enum RunnerExecutionMode
22+
{
23+
/// <summary>
24+
/// The runner operates in a connected mode, interacting with the remote API.
25+
/// In this mode, the runner depends on external services and APIs for its functionality.
26+
/// </summary>
27+
[EnumMember(Value = "connected")]
28+
Connected,
29+
/// <summary>
30+
/// The runner operates in a standalone mode, functioning independently without relying on the remote API.
31+
/// This mode is ideal for scenarios where external dependencies are unavailable or not required.
32+
/// </summary>
33+
[EnumMember(Value = "standalone")]
34+
StandAlone
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
using System.Runtime.Serialization;
15+
16+
namespace Synapse.Runner.Configuration;
17+
18+
/// <summary>
19+
/// Represents the options used to configure a Synapse Runner's logging
20+
/// </summary>
21+
[DataContract]
22+
public class RunnerLoggingOptions
23+
{
24+
25+
/// <summary>
26+
/// Gets/sets the path to the file, if any, to output logs to
27+
/// </summary>
28+
public virtual string? OutputFilePath { get; set; }
29+
30+
}

src/runner/Synapse.Runner/Configuration/RunnerOptions.cs

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ namespace Synapse.Runner.Configuration;
2323
public class RunnerOptions
2424
{
2525

26+
/// <summary>
27+
/// Gets/sets the runner's execution mode
28+
/// </summary>
29+
public RunnerExecutionMode ExecutionMode => string.IsNullOrWhiteSpace(this.Workflow.DefinitionFilePath) ? RunnerExecutionMode.Connected : RunnerExecutionMode.StandAlone;
30+
2631
/// <summary>
2732
/// Gets/sets the options used to configure the Synapse API the runner must use
2833
/// </summary>
@@ -43,6 +48,11 @@ public class RunnerOptions
4348
/// </summary>
4449
public virtual RunnerContainerOptions Containers { get; set; } = new();
4550

51+
/// <summary>
52+
/// Gets/sets the options used to configure a Synapse Runner's logging
53+
/// </summary>
54+
public virtual RunnerLoggingOptions Logging { get; set; } = new();
55+
4656
/// <summary>
4757
/// Gets the options used to configure the secrets of the Synapse Runner
4858
/// </summary>

src/runner/Synapse.Runner/Configuration/WorkflowOptions.cs

+34-6
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,52 @@ public class WorkflowOptions
2424
/// </summary>
2525
public WorkflowOptions()
2626
{
27-
this.Instance = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Workflow.Instance)!;
27+
this.InstanceQualifiedName = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Workflow.Instance)!;
2828
}
2929

3030
/// <summary>
31-
/// Gets/sets the qualified name of the workflow instance to run
31+
/// Gets/sets the qualified name of the workflow instance to run. Required if the execution mode has been set to <see cref="RunnerExecutionMode.Connected"/>, otherwise ignored
3232
/// </summary>
33-
public virtual string Instance { get; set; }
33+
public virtual string? InstanceQualifiedName { get; set; }
34+
35+
/// <summary>
36+
/// Gets/sets the name of the definition's file, if any. Required if the execution mode has been set to <see cref="RunnerExecutionMode.StandAlone"/>, otherwise ignored
37+
/// </summary>
38+
public virtual string? DefinitionFilePath { get; set; }
39+
40+
/// <summary>
41+
/// Gets/sets the name of the file, if any, that defines the input of to the workflow to run. Ignored if the execution mode has been set to <see cref="RunnerExecutionMode.Connected"/>
42+
/// </summary>
43+
public virtual string? InputFilePath { get; set; }
44+
45+
/// <summary>
46+
/// Gets/sets the name of the file, if any, to write the workflow's output to. Ignored if the execution mode has been set to <see cref="RunnerExecutionMode.Connected"/>
47+
/// </summary>
48+
public virtual string? OutputFilePath { get; set; }
49+
50+
/// <summary>
51+
/// Gets/sets the workflow's output format. Ignored if execution mode has been set to <see cref="RunnerExecutionMode.Connected"/>
52+
/// </summary>
53+
public virtual WorkflowOutputFormat OutputFormat { get; set; }
3454

3555
/// <summary>
3656
/// Gets the namespace of the workflow instance to run
3757
/// </summary>
3858
/// <returns>The namespace of the workflow instance to run</returns>
39-
public virtual string GetInstanceNamespace() => this.Instance.Split('.', StringSplitOptions.RemoveEmptyEntries).Last();
59+
public virtual string GetInstanceNamespace()
60+
{
61+
if (string.IsNullOrWhiteSpace(this.InstanceQualifiedName)) throw new NullReferenceException("The instance qualified name is null or empty");
62+
return this.InstanceQualifiedName.Split('.', StringSplitOptions.RemoveEmptyEntries).Last();
63+
}
4064

4165
/// <summary>
4266
/// Gets the name of the workflow instance to run
4367
/// </summary>
4468
/// <returns>The name of the workflow instance to run</returns>
45-
public virtual string GetInstanceName() => this.Instance.Split('.', StringSplitOptions.RemoveEmptyEntries).First();
69+
public virtual string GetInstanceName()
70+
{
71+
if (string.IsNullOrWhiteSpace(this.InstanceQualifiedName)) throw new NullReferenceException("The instance qualified name is null or empty");
72+
return this.InstanceQualifiedName.Split('.', StringSplitOptions.RemoveEmptyEntries).First();
73+
}
4674

47-
}
75+
}

0 commit comments

Comments
 (0)