Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kubernetes runtime #388

Merged
merged 20 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5964dcc
fix(Solution): Fixed all project files by adding package description,…
cdavernas Sep 4, 2024
ab07578
feat(Runtime): Refactored runtimes by removing Containerized runtime …
cdavernas Sep 4, 2024
58a9d96
feat(Runner): Updated the WorkflowExecutionContext to publish cloud e…
cdavernas Sep 5, 2024
caa5139
Merge pull request #389 from serverlessworkflow/feat-emit-cloud-events
cdavernas Sep 5, 2024
6436706
fix(Runner): Fixed the Runner to inject and configure an IContainerPl…
cdavernas Sep 6, 2024
5e6c4ec
Merge pull request #390 from serverlessworkflow/fix-runner-container-…
cdavernas Sep 6, 2024
a8cae54
fix(Solution): Fixed/renamed/added environment variables
cdavernas Sep 6, 2024
5920092
Merge pull request #391 from serverlessworkflow/fix-environment-varia…
cdavernas Sep 6, 2024
b2b21ef
fix(Solution): Updated ServerlessWorkflow packages to latest version,…
cdavernas Sep 6, 2024
9c6de69
Merge pull request #392 from serverlessworkflow/feat-update-sw-packages
cdavernas Sep 6, 2024
36ef782
fix(Dashboard): handled conditional tasks in the graph
JBBianchi Sep 6, 2024
5bc3a56
Merge pull request #393 from serverlessworkflow/fix-graph-conditional…
cdavernas Sep 6, 2024
60a8dd1
feat(Api): Added a new ICloudEventPublisher service interface - and d…
cdavernas Sep 7, 2024
d57ecae
Merge pull request #394 from serverlessworkflow/feat-cloud-event-publ…
cdavernas Sep 7, 2024
40ac1e6
fix(Solution): Updated solution packages
cdavernas Sep 8, 2024
bdcf723
fix(Solution): Fixed all project files by adding package description,…
cdavernas Sep 4, 2024
20bc1c0
feat(Runtime): Refactored runtimes by removing Containerized runtime …
cdavernas Sep 4, 2024
0c8eb26
fix(Solution): Updated solution packages
cdavernas Sep 8, 2024
6668e0c
fix(Solution): Rebased onto main
cdavernas Sep 8, 2024
9db918c
fix(Solution): Fixed Polly package reference
cdavernas Sep 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions Synapse.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runner", "runner", "{1DA47E
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core", "src\core\Synapse.Core\Synapse.Core.csproj", "{F2804D69-04C9-463D-B5E5-D3185163EBC0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core.Infrastructure.Containers.Docker", "src\core\Synapse.Core.Infrastructure.Containers.Docker\Synapse.Core.Infrastructure.Containers.Docker.csproj", "{40EB503E-6E97-4375-A172-6EF55F9E0FF3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{63715FC0-736D-4972-A865-41126155DF45}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Dashboard", "src\dashboard\Synapse.Dashboard\Synapse.Dashboard.csproj", "{A9BB7219-B24B-4E40-B10A-69E618BDA272}"
Expand Down Expand Up @@ -58,8 +56,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Abstraction
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Native", "src\runtime\Synapse.Runtime.Native\Synapse.Runtime.Native.csproj", "{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Containerized", "src\runtime\Synapse.Runtime.Containerized\Synapse.Runtime.Containerized.csproj", "{F327B8F1-9A13-4924-AE1B-E69788AC73E7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runner", "src\runner\Synapse.Runner\Synapse.Runner.csproj", "{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Dashboard.StateManagement", "src\dashboard\Synapse.Dashboard.StateManagement\Synapse.Dashboard.StateManagement.csproj", "{91EF9F64-4997-407C-B353-C26B1421D0FB}"
Expand Down Expand Up @@ -132,6 +128,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{
deployments\helm\templates\services.yaml = deployments\helm\templates\services.yaml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Docker", "src\runtime\Synapse.Runtime.Docker\Synapse.Runtime.Docker.csproj", "{8FF58403-9E13-4F58-864F-E6FBC877BF37}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Kubernetes", "src\runtime\Synapse.Runtime.Kubernetes\Synapse.Runtime.Kubernetes.csproj", "{9B37AA4A-A342-4A41-A2A1-C8466825A70A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core.Infrastructure.Containers.Docker", "src\core\Synapse.Core.Infrastructure.Containers.Docker\Synapse.Core.Infrastructure.Containers.Docker.csproj", "{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -142,10 +144,6 @@ Global
{F2804D69-04C9-463D-B5E5-D3185163EBC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2804D69-04C9-463D-B5E5-D3185163EBC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2804D69-04C9-463D-B5E5-D3185163EBC0}.Release|Any CPU.Build.0 = Release|Any CPU
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Release|Any CPU.Build.0 = Release|Any CPU
{A9BB7219-B24B-4E40-B10A-69E618BDA272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9BB7219-B24B-4E40-B10A-69E618BDA272}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BB7219-B24B-4E40-B10A-69E618BDA272}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -190,10 +188,6 @@ Global
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Release|Any CPU.Build.0 = Release|Any CPU
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Release|Any CPU.Build.0 = Release|Any CPU
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -218,6 +212,18 @@ Global
{A2D3AFB0-C7E0-4778-9D0A-DFCE0E24AF17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2D3AFB0-C7E0-4778-9D0A-DFCE0E24AF17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2D3AFB0-C7E0-4778-9D0A-DFCE0E24AF17}.Release|Any CPU.Build.0 = Release|Any CPU
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Release|Any CPU.Build.0 = Release|Any CPU
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Release|Any CPU.Build.0 = Release|Any CPU
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -229,7 +235,6 @@ Global
{32EAD165-3D99-42CD-B3AF-05136DCC7F35} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
{1DA47E5F-B23A-4D3C-96AA-4BD2662AB946} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
{F2804D69-04C9-463D-B5E5-D3185163EBC0} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
{40EB503E-6E97-4375-A172-6EF55F9E0FF3} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
{63715FC0-736D-4972-A865-41126155DF45} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
{A9BB7219-B24B-4E40-B10A-69E618BDA272} = {7DF998B8-0FB1-470E-8ED0-EA1CC7B16901}
{327FF68E-E729-4616-B1BE-B262A95890A2} = {63715FC0-736D-4972-A865-41126155DF45}
Expand All @@ -243,7 +248,6 @@ Global
{175CE1C5-FE17-4C8B-8823-E812BAD4E527} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
{A0E5E7F2-8C9C-4F36-B3FD-C09074893023} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
{F327B8F1-9A13-4924-AE1B-E69788AC73E7} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018} = {1DA47E5F-B23A-4D3C-96AA-4BD2662AB946}
{91EF9F64-4997-407C-B353-C26B1421D0FB} = {7DF998B8-0FB1-470E-8ED0-EA1CC7B16901}
{A9085F4A-5FDF-4F4A-B267-A03BC5E0FDB0} = {32EAD165-3D99-42CD-B3AF-05136DCC7F35}
Expand All @@ -255,6 +259,9 @@ Global
{2A6EE5DF-BD7E-4CC6-BB9B-7BE5FC128302} = {750922F9-5C47-42FE-945F-576818E6DEC9}
{B6A96DC3-E57A-4022-9279-1DB57744C893} = {562C91A3-6E91-4489-9D9D-064E7436D900}
{3F5CCCE8-46F8-4873-8EF9-38E14EAE7E01} = {B6A96DC3-E57A-4022-9279-1DB57744C893}
{8FF58403-9E13-4F58-864F-E6FBC877BF37} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
{9B37AA4A-A342-4A41-A2A1-C8466825A70A} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A6C03D6-355A-4B39-9F2B-D0FDE429C0E2}
Expand Down
Binary file added assets/images/transparent_logomark_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion deployments/docker-compose/docker-compose.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
SYNAPSE_DASHBOARD_SERVE: true
SYNAPSE_API_AUTH_TOKEN_FILE: /app/tokens.yaml
SYNAPSE_API_JWT_AUTHORITY: http://api:8080
SYNAPSE_API_CLOUD_EVENTS_ENDPOINT: https://webhook.site/a4aff725-0711-48b2-a9d2-5d1b806d04d0
volumes:
- ./config/tokens.yaml:/app/tokens.yaml
ports:
Expand All @@ -29,7 +30,9 @@ services:
CONNECTIONSTRINGS__REDIS: ${GARNET_URI}
SYNAPSE_OPERATOR_NAMESPACE: default
SYNAPSE_OPERATOR_NAME: operator-1
SYNAPSE_OPERATOR_RUNNER_API: http://api:8080
SYNAPSE_RUNNER_API: http://api:8080
SYNAPSE_RUNNER_LIFECYCLE_EVENTS: true
SYNAPSE_RUNNER_CONTAINER_PLATFORM: docker
DOCKER_HOST: unix:///var/run/docker.sock
extra_hosts:
- "host.docker.internal:host-gateway"
Expand Down
5 changes: 4 additions & 1 deletion deployments/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
SYNAPSE_DASHBOARD_SERVE: true
SYNAPSE_API_AUTH_TOKEN_FILE: /app/tokens.yaml
SYNAPSE_API_JWT_AUTHORITY: http://api:8080
SYNAPSE_API_CLOUD_EVENTS_ENDPOINT: https://webhook.site/a4aff725-0711-48b2-a9d2-5d1b806d04d0
volumes:
- ./config/tokens.yaml:/app/tokens.yaml
ports:
Expand All @@ -25,7 +26,9 @@ services:
CONNECTIONSTRINGS__REDIS: ${GARNET_URI}
SYNAPSE_OPERATOR_NAMESPACE: default
SYNAPSE_OPERATOR_NAME: operator-1
SYNAPSE_OPERATOR_RUNNER_API: http://api:8080
SYNAPSE_RUNNER_API: http://api:8080
SYNAPSE_RUNNER_LIFECYCLE_EVENTS: true
SYNAPSE_RUNNER_CONTAINER_PLATFORM: docker
DOCKER_HOST: unix:///var/run/docker.sock
extra_hosts:
- "host.docker.internal:host-gateway"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Neuroglia.Eventing.CloudEvents;
using Neuroglia.Serialization;
using Synapse.Api.Application.Configuration;
using System.Text;
using Synapse.Api.Application.Services;

namespace Synapse.Api.Application.Commands.Events;

Expand All @@ -38,28 +34,15 @@ public class PublishCloudEventCommand(CloudEvent e)
/// <summary>
/// Represents the service used to handle <see cref="PublishCloudEventCommand"/>s
/// </summary>
/// <param name="logger">The service used to perform logging</param>
/// <param name="options">The service used to access the current <see cref="ApiServerOptions"/></param>
/// <param name="jsonSerializer">The service used to serialize/deserialize data to/from JSON</param>
/// <param name="httpClient">The service used to perform HTTP requests</param>
public class PublishCloudEventCommandHandler(ILogger<PublishCloudEventCommandHandler> logger, IOptions<ApiServerOptions> options, IJsonSerializer jsonSerializer, HttpClient httpClient)
/// <param name="cloudEventPublisher">The service used to publish <see cref="CloudEvent"/>s</param>
public class PublishCloudEventCommandHandler(ICloudEventPublisher cloudEventPublisher)
: ICommandHandler<PublishCloudEventCommand>
{

/// <inheritdoc/>
public virtual async Task<IOperationResult> HandleAsync(PublishCloudEventCommand command, CancellationToken cancellationToken = default)
{
if (options.Value.Events?.Endpoint == null) return this.Ok();
var json = jsonSerializer.SerializeToText(command.CloudEvent);
using var content = new StringContent(json, Encoding.UTF8, CloudEventContentType.Json);
using var request = new HttpRequestMessage(HttpMethod.Post, options.Value.Events.Endpoint) { Content = content };
using var response = await httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
json = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
logger.LogError("An error occurred while publishing the cloud event with id '{eventId}' to the configure endpoint '{endpoint}': {ex}", command.CloudEvent.Id, options.Value.Events.Endpoint, json);
response.EnsureSuccessStatusCode();
}
await cloudEventPublisher.PublishAsync(command.CloudEvent, cancellationToken).ConfigureAwait(false);
return this.Ok();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,23 @@ namespace Synapse.Api.Application.Configuration;
/// <summary>
/// Represents the options used to configure the Cloud Events published by the Synapse API server
/// </summary>
public class CloudEventOptions
public class ApiServerCloudEventOptions
{

/// <summary>
/// Initializes a new <see cref="CloudEvent"/>
/// </summary>
/// <exception cref="Exception"></exception>
public ApiServerCloudEventOptions()
{
var env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Api.CloudEvents.Endpoint);
if (!string.IsNullOrWhiteSpace(env))
{
if (!Uri.TryCreate(env, UriKind.Absolute, out var endpoint)) throw new Exception("The Cloud Events endpoint must be a valid absolute URI");
this.Endpoint = endpoint;
}
}

/// <summary>
/// Gets/sets the uri, if any, to which to publish <see cref="CloudEvent"/>s
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public ApiServerOptions()
/// <summary>
/// Gets/sets the options used to configure the cloud events published by the Synapse API Server
/// </summary>
public virtual CloudEventOptions? Events { get; set; }
public virtual ApiServerCloudEventOptions CloudEvents { get; set; } = new();

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Neuroglia.Data.Infrastructure;
using Neuroglia.Security;
using Synapse.Api.Application.Commands.Documents;
Expand All @@ -21,6 +22,7 @@
using Synapse.Api.Application.Queries.Resources.Generic;
using Synapse.Api.Application.Queries.Users;
using Synapse.Api.Application.Queries.WorkflowInstances;
using Synapse.Api.Application.Services;
using Synapse.Resources;

namespace Synapse.Api.Application;
Expand All @@ -41,6 +43,10 @@ public static IServiceCollection AddSynapseApi(this IServiceCollection services)
services.AddApiCommands();
services.AddApiQueries();

services.AddSingleton<CloudEventPublisher>();
services.AddSingleton<ICloudEventPublisher>(provider => provider.GetRequiredService<CloudEventPublisher>());
services.AddSingleton<IHostedService>(provider => provider.GetRequiredService<CloudEventPublisher>());

return services;
}

Expand Down
Loading
Loading