Skip to content

Commit 6438ee5

Browse files
committed
fix(Solution): Reorganized solution and renamed Infrastructure project
feat(Runtime): Added Runtime abstractions and default Native implementations WIP Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
1 parent 6430fb8 commit 6438ee5

File tree

122 files changed

+1524
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1524
-121
lines changed

Synapse.sln

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dashboard", "dashboard", "{
1111
EndProject
1212
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cli", "cli", "{D3B3B95D-B598-4B13-B754-4A7E530405A6}"
1313
EndProject
14-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{32EAD165-3D99-42CD-B3AF-05136DCC7F35}"
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "operator", "operator", "{32EAD165-3D99-42CD-B3AF-05136DCC7F35}"
1515
EndProject
16-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "worker", "worker", "{1DA47E5F-B23A-4D3C-96AA-4BD2662AB946}"
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runner", "runner", "{1DA47E5F-B23A-4D3C-96AA-4BD2662AB946}"
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core", "src\core\Synapse.Core\Synapse.Core.csproj", "{F2804D69-04C9-463D-B5E5-D3185163EBC0}"
1919
EndProject
20-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Infrastructure.Containers.Docker", "src\core\Synapse.Infrastructure.Containers.Docker\Synapse.Infrastructure.Containers.Docker.csproj", "{40EB503E-6E97-4375-A172-6EF55F9E0FF3}"
20+
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}"
2121
EndProject
2222
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{63715FC0-736D-4972-A865-41126155DF45}"
2323
EndProject
@@ -35,16 +35,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F041A1CB
3535
EndProject
3636
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Api.Server", "src\api\Synapse.Api.Server\Synapse.Api.Server.csproj", "{8DFC5C6C-830A-481F-8E88-632CF5065793}"
3737
EndProject
38-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Infrastructure", "src\core\Synapse.Infrastructure\Synapse.Infrastructure.csproj", "{03F9EC99-55D5-4880-9972-592A366418FD}"
39-
EndProject
40-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Worker.Application", "src\worker\Synapse.Worker.Application\Synapse.Worker.Application.csproj", "{1C655B22-507A-434D-941A-F63F0BC84A5A}"
38+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core.Infrastructure", "src\core\Synapse.Core.Infrastructure\Synapse.Core.Infrastructure.csproj", "{03F9EC99-55D5-4880-9972-592A366418FD}"
4139
EndProject
4240
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.IntegrationTests", "tests\Synapse.IntegrationTests\Synapse.IntegrationTests.csproj", "{6F7ED286-A02C-4E78-9FE3-2689BD94B97C}"
4341
EndProject
4442
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.UnitTests", "tests\Synapse.UnitTests\Synapse.UnitTests.csproj", "{CB1DF439-BFBA-408D-BC09-3FF94E6C4F0F}"
4543
EndProject
4644
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Api.Client.Core", "src\api\Synapse.Api.Client.Core\Synapse.Api.Client.Core.csproj", "{3E650D2D-B018-4056-8922-FC7DF68233B1}"
4745
EndProject
46+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runner.Application", "src\runner\Synapse.Runner.Application\Synapse.Runner.Application.csproj", "{DDC90022-43B5-48CC-A967-0826C2A385F2}"
47+
EndProject
48+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Operator.Application", "src\operator\Synapse.Operator.Application\Synapse.Operator.Application.csproj", "{7627C036-B55A-479C-AB0D-C859D4A11238}"
49+
EndProject
50+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runtime", "runtime", "{175CE1C5-FE17-4C8B-8823-E812BAD4E527}"
51+
EndProject
52+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Abstractions", "src\runtime\Synapse.Runtime.Abstractions\Synapse.Runtime.Abstractions.csproj", "{A0E5E7F2-8C9C-4F36-B3FD-C09074893023}"
53+
EndProject
54+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Native", "src\runtime\Synapse.Runtime.Native\Synapse.Runtime.Native.csproj", "{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}"
55+
EndProject
56+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Containerized", "src\runtime\Synapse.Runtime.Containerized\Synapse.Runtime.Containerized.csproj", "{F327B8F1-9A13-4924-AE1B-E69788AC73E7}"
57+
EndProject
4858
Global
4959
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5060
Debug|Any CPU = Debug|Any CPU
@@ -83,10 +93,6 @@ Global
8393
{03F9EC99-55D5-4880-9972-592A366418FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
8494
{03F9EC99-55D5-4880-9972-592A366418FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
8595
{03F9EC99-55D5-4880-9972-592A366418FD}.Release|Any CPU.Build.0 = Release|Any CPU
86-
{1C655B22-507A-434D-941A-F63F0BC84A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87-
{1C655B22-507A-434D-941A-F63F0BC84A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
88-
{1C655B22-507A-434D-941A-F63F0BC84A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
89-
{1C655B22-507A-434D-941A-F63F0BC84A5A}.Release|Any CPU.Build.0 = Release|Any CPU
9096
{6F7ED286-A02C-4E78-9FE3-2689BD94B97C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
9197
{6F7ED286-A02C-4E78-9FE3-2689BD94B97C}.Debug|Any CPU.Build.0 = Debug|Any CPU
9298
{6F7ED286-A02C-4E78-9FE3-2689BD94B97C}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -99,6 +105,26 @@ Global
99105
{3E650D2D-B018-4056-8922-FC7DF68233B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
100106
{3E650D2D-B018-4056-8922-FC7DF68233B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
101107
{3E650D2D-B018-4056-8922-FC7DF68233B1}.Release|Any CPU.Build.0 = Release|Any CPU
108+
{DDC90022-43B5-48CC-A967-0826C2A385F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109+
{DDC90022-43B5-48CC-A967-0826C2A385F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
110+
{DDC90022-43B5-48CC-A967-0826C2A385F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
111+
{DDC90022-43B5-48CC-A967-0826C2A385F2}.Release|Any CPU.Build.0 = Release|Any CPU
112+
{7627C036-B55A-479C-AB0D-C859D4A11238}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
113+
{7627C036-B55A-479C-AB0D-C859D4A11238}.Debug|Any CPU.Build.0 = Debug|Any CPU
114+
{7627C036-B55A-479C-AB0D-C859D4A11238}.Release|Any CPU.ActiveCfg = Release|Any CPU
115+
{7627C036-B55A-479C-AB0D-C859D4A11238}.Release|Any CPU.Build.0 = Release|Any CPU
116+
{A0E5E7F2-8C9C-4F36-B3FD-C09074893023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
117+
{A0E5E7F2-8C9C-4F36-B3FD-C09074893023}.Debug|Any CPU.Build.0 = Debug|Any CPU
118+
{A0E5E7F2-8C9C-4F36-B3FD-C09074893023}.Release|Any CPU.ActiveCfg = Release|Any CPU
119+
{A0E5E7F2-8C9C-4F36-B3FD-C09074893023}.Release|Any CPU.Build.0 = Release|Any CPU
120+
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
121+
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Debug|Any CPU.Build.0 = Debug|Any CPU
122+
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Release|Any CPU.ActiveCfg = Release|Any CPU
123+
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Release|Any CPU.Build.0 = Release|Any CPU
124+
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
125+
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
126+
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
127+
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Release|Any CPU.Build.0 = Release|Any CPU
102128
EndGlobalSection
103129
GlobalSection(SolutionProperties) = preSolution
104130
HideSolutionNode = FALSE
@@ -118,10 +144,15 @@ Global
118144
{F8D7F756-16A1-420B-AED4-8EF9A65B640E} = {63715FC0-736D-4972-A865-41126155DF45}
119145
{8DFC5C6C-830A-481F-8E88-632CF5065793} = {63715FC0-736D-4972-A865-41126155DF45}
120146
{03F9EC99-55D5-4880-9972-592A366418FD} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
121-
{1C655B22-507A-434D-941A-F63F0BC84A5A} = {1DA47E5F-B23A-4D3C-96AA-4BD2662AB946}
122147
{6F7ED286-A02C-4E78-9FE3-2689BD94B97C} = {F041A1CB-45FA-4432-BAD2-DE2EE174C6FC}
123148
{CB1DF439-BFBA-408D-BC09-3FF94E6C4F0F} = {F041A1CB-45FA-4432-BAD2-DE2EE174C6FC}
124149
{3E650D2D-B018-4056-8922-FC7DF68233B1} = {63715FC0-736D-4972-A865-41126155DF45}
150+
{DDC90022-43B5-48CC-A967-0826C2A385F2} = {1DA47E5F-B23A-4D3C-96AA-4BD2662AB946}
151+
{7627C036-B55A-479C-AB0D-C859D4A11238} = {32EAD165-3D99-42CD-B3AF-05136DCC7F35}
152+
{175CE1C5-FE17-4C8B-8823-E812BAD4E527} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
153+
{A0E5E7F2-8C9C-4F36-B3FD-C09074893023} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
154+
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
155+
{F327B8F1-9A13-4924-AE1B-E69788AC73E7} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
125156
EndGlobalSection
126157
GlobalSection(ExtensibilityGlobals) = postSolution
127158
SolutionGuid = {2A6C03D6-355A-4B39-9F2B-D0FDE429C0E2}

src/api/Synapse.Api.Application/Extensions/IServiceCollectionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ public static IServiceCollection AddSynapseApi(this IServiceCollection services,
5959
services.AddPlugin(typeof(IDatabase), string.IsNullOrWhiteSpace(redisConnectionString) ? null : provider => provider.GetRequiredService<RedisDatabase>(), serviceLifetime: ServiceLifetime.Scoped);
6060

6161
if (!string.IsNullOrWhiteSpace(redisConnectionString)) services.AddRedisDatabase(redisConnectionString, ServiceLifetime.Scoped);
62-
services.AddHostedService<Infrastructure.Services.DatabaseInitializer>();
62+
services.AddHostedService<Core.Infrastructure.Services.DatabaseInitializer>();
6363

6464
services.AddPlugin(typeof(IRepository<Document>), provider => provider.GetRequiredService<MongoRepository<Document, string>>(), serviceLifetime: ServiceLifetime.Scoped);
65-
services.AddMongoDatabase("cloud-flows");
65+
services.AddMongoDatabase("synapse");
6666
services.AddMongoRepository<Document, string>(lifetime: ServiceLifetime.Scoped);
6767

6868
services.AddScoped<IResourceRepository, ResourceRepository>();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<ProjectReference Include="..\..\core\Synapse.Infrastructure\Synapse.Infrastructure.csproj" />
19+
<ProjectReference Include="..\..\core\Synapse.Core.Infrastructure\Synapse.Core.Infrastructure.csproj" />
2020
<ProjectReference Include="..\Synapse.Api.Client.Core\Synapse.Api.Client.Core.csproj" />
2121
</ItemGroup>
2222

src/api/Synapse.Api.Http/Extensions/IServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static IServiceCollection AddSynapseHttpApi(this IServiceCollection servi
5858
License = new OpenApiLicense()
5959
{
6060
Name = "Apache-2.0",
61-
Url = new("https://raw.githubusercontent.com/cloud-flows/dsl/main/LICENSE")
61+
Url = new("https://raw.githubusercontent.com/synapse/dsl/main/LICENSE")
6262
},
6363
Contact = new()
6464
{

src/core/Synapse.Infrastructure.Containers.Docker/DockerContainer.cs renamed to src/core/Synapse.Core.Infrastructure.Containers.Docker/DockerContainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
using Synapse.Infrastructure.Services;
14+
using Synapse.Core.Infrastructure.Services;
1515

16-
namespace Synapse.Infrastructure.Containers;
16+
namespace Synapse.Core.Infrastructure.Containers;
1717

1818
/// <summary>
1919
/// Represents a Docker <see cref="IContainer"/>

src/core/Synapse.Infrastructure.Containers.Docker/DockerContainerPlatform.cs renamed to src/core/Synapse.Core.Infrastructure.Containers.Docker/DockerContainerPlatform.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
using Synapse.Infrastructure.Services;
14+
using Synapse.Core.Infrastructure.Services;
1515

16-
namespace Synapse.Infrastructure.Containers;
16+
namespace Synapse.Core.Infrastructure.Containers;
1717

1818
/// <summary>
1919
/// Represents the Docker implementation of the <see cref="IContainerPlatform"/> interface
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
using Synapse.Infrastructure.Services;
14+
using Synapse.Core.Infrastructure.Services;
1515
using Microsoft.Extensions.DependencyInjection;
1616
using Microsoft.Extensions.DependencyInjection.Extensions;
1717

18-
namespace Synapse.Infrastructure.Containers;
18+
namespace Synapse.Core.Infrastructure.Containers;
1919

2020
/// <summary>
2121
/// Defines extensions for <see cref="IServiceCollection"/>s

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<ItemGroup>
1515
<ProjectReference Include="..\Synapse.Core\Synapse.Core.csproj" />
16-
<ProjectReference Include="..\Synapse.Infrastructure\Synapse.Infrastructure.csproj" />
16+
<ProjectReference Include="..\Synapse.Core.Infrastructure\Synapse.Core.Infrastructure.csproj" />
1717
</ItemGroup>
1818

1919
</Project>

src/core/Synapse.Infrastructure/AuthorizationInfo.cs renamed to src/core/Synapse.Core.Infrastructure/AuthorizationInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
using Synapse.Infrastructure.Services;
14+
using Synapse.Core.Infrastructure.Services;
1515
using ServerlessWorkflow.Sdk;
1616
using Microsoft.Extensions.DependencyInjection;
1717
using System.Text;

src/core/Synapse.Infrastructure/Services/DatabaseInitializer.cs renamed to src/core/Synapse.Core.Infrastructure/Services/DatabaseInitializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
using Microsoft.Extensions.Logging;
1515
using Neuroglia.Data.Infrastructure.ResourceOriented;
1616

17-
namespace Synapse.Infrastructure.Services;
17+
namespace Synapse.Core.Infrastructure.Services;
1818

1919
/// <summary>
2020
/// Represents the service used to initialize the Synapse resource database

src/core/Synapse.Infrastructure/Services/ExternalResourceProvider.cs renamed to src/core/Synapse.Core.Infrastructure/Services/ExternalResourceProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
namespace Synapse.Infrastructure.Services;
14+
namespace Synapse.Core.Infrastructure.Services;
1515

1616
/// <summary>
1717
/// Represents the default implementation of the <see cref="IExternalResourceProvider"/> interface

src/core/Synapse.Infrastructure/Services/Interfaces/IContainer.cs renamed to src/core/Synapse.Core.Infrastructure/Services/Interfaces/IContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
namespace Synapse.Infrastructure.Services;
14+
namespace Synapse.Core.Infrastructure.Services;
1515

1616
/// <summary>
1717
/// Defines the fundamentals of a container

src/core/Synapse.Infrastructure/Services/Interfaces/IContainerPlatform.cs renamed to src/core/Synapse.Core.Infrastructure/Services/Interfaces/IContainerPlatform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
using ServerlessWorkflow.Sdk.Models.Processes;
1515

16-
namespace Synapse.Infrastructure.Services;
16+
namespace Synapse.Core.Infrastructure.Services;
1717

1818
/// <summary>
1919
/// Defines the fundamentals of a service used to interact with a container platform

src/core/Synapse.Infrastructure/Services/Interfaces/IExternalResourceProvider.cs renamed to src/core/Synapse.Core.Infrastructure/Services/Interfaces/IExternalResourceProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
namespace Synapse.Infrastructure.Services;
14+
namespace Synapse.Core.Infrastructure.Services;
1515

1616
/// <summary>
1717
/// Defines the fundamentals of a service used to provide external resources

src/core/Synapse.Infrastructure/Services/Interfaces/IOAuth2TokenManager.cs renamed to src/core/Synapse.Core.Infrastructure/Services/Interfaces/IOAuth2TokenManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
using ServerlessWorkflow.Sdk.Models.Authentication;
1515

16-
namespace Synapse.Infrastructure.Services;
16+
namespace Synapse.Core.Infrastructure.Services;
1717

1818
/// <summary>
1919
/// Defines the fundamentals of a service used to manage <see cref="OAuth2Token"/>s

src/core/Synapse.Infrastructure/Services/OAuth2TokenManager.cs renamed to src/core/Synapse.Core.Infrastructure/Services/OAuth2TokenManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
using Neuroglia.Serialization;
1818
using System.Collections.Concurrent;
1919

20-
namespace Synapse.Infrastructure.Services;
20+
namespace Synapse.Core.Infrastructure.Services;
2121

2222
/// <summary>
2323
/// Represents the default implementation of the <see cref="IOAuth2TokenManager"/> interface

src/core/Synapse.Core/Extensions/ExceptionExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Net;
2-
using System.Security.Cryptography;
32

43
namespace Synapse;
54

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Semver;
2+
3+
namespace Synapse;
4+
5+
/// <summary>
6+
/// Defines extensions for <see cref="IEnumerable{T}"/> instances that contains <see cref="WorkflowDefinition"/>s
7+
/// </summary>
8+
public static class WorkflowDefinitionEnumerableExtensions
9+
{
10+
11+
/// <summary>
12+
/// Gets the latest version of the <see cref="WorkflowDefinition"/>
13+
/// </summary>
14+
/// <param name="definitions">An <see cref="IEnumerable{T}"/> containing the <see cref="WorkflowDefinition"/>s to get the latest of</param>
15+
/// <returns>The latest <see cref="WorkflowDefinition"/></returns>
16+
public static WorkflowDefinition GetLatest(this IEnumerable<WorkflowDefinition> definitions) => definitions.OrderByDescending(wf => SemVersion.Parse(wf.Document.Version, SemVersionStyles.Strict)).First();
17+
18+
/// <summary>
19+
/// Gets the specified <see cref="WorkflowDefinition"/> version
20+
/// </summary>
21+
/// <param name="definitions">An <see cref="IEnumerable{T}"/> containing the <see cref="WorkflowDefinition"/>s to get the specified version from</param>
22+
/// <param name="version">The version of the <see cref="WorkflowDefinition"/> to get</param>
23+
/// <returns>The <see cref="WorkflowDefinition"/> with the specified version, if any</returns>
24+
public static WorkflowDefinition? Get(this IEnumerable<WorkflowDefinition> definitions, string version) => definitions.FirstOrDefault(wf => wf.Document.Version == version);
25+
26+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright © 2024-Present Neuroglia SRL. All rights reserved.
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 Neuroglia.Data.Infrastructure.ResourceOriented;
15+
16+
namespace Synapse.Resources;
17+
18+
/// <summary>
19+
/// Represents the resource used to describe and configure an operator
20+
/// </summary>
21+
[DataContract]
22+
public record Operator
23+
: Resource<OperatorSpec>
24+
{
25+
26+
/// <summary>
27+
/// Gets the <see cref="Operator"/>'s resource type
28+
/// </summary>
29+
public static readonly ResourceDefinitionInfo ResourceDefinition = new OperatorResourceDefinition()!;
30+
31+
/// <inheritdoc/>
32+
public Operator() : base(ResourceDefinition) { }
33+
34+
/// <inheritdoc/>
35+
public Operator(ResourceMetadata metadata, OperatorSpec spec) : base(ResourceDefinition, metadata, spec) { }
36+
37+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright © 2024-Present Neuroglia SRL. All rights reserved.
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 Neuroglia.Data.Infrastructure.ResourceOriented;
15+
using Neuroglia.Serialization.Yaml;
16+
17+
namespace Synapse.Resources;
18+
19+
/// <summary>
20+
/// Represents the definition of an <see cref="Operator"/> <see cref="Resource"/>
21+
/// </summary>
22+
[DataContract]
23+
public record OperatorResourceDefinition
24+
: ResourceDefinition
25+
{
26+
27+
/// <summary>
28+
/// Gets the definition of <see cref="ResourceDefinition"/>s
29+
/// </summary>
30+
public static new ResourceDefinition Instance { get; set; }
31+
/// <summary>
32+
/// Gets/sets the group resource definitions belong to
33+
/// </summary>
34+
public static new string ResourceGroup { get; set; }
35+
/// <summary>
36+
/// Gets/sets the resource version of resource definitions
37+
/// </summary>
38+
public static new string ResourceVersion { get; set; }
39+
/// <summary>
40+
/// Gets/sets the plural name of resource definitions
41+
/// </summary>
42+
public static new string ResourcePlural { get; set; }
43+
/// <summary>
44+
/// Gets/sets the kind of resource definitions
45+
/// </summary>
46+
public static new string ResourceKind { get; set; }
47+
48+
static OperatorResourceDefinition()
49+
{
50+
using var stream = typeof(Workflow).Assembly.GetManifestResourceStream($"{typeof(Operator).Namespace}.{nameof(Operator)}.yaml")!;
51+
using var streamReader = new StreamReader(stream);
52+
Instance = YamlSerializer.Default.Deserialize<ResourceDefinition>(streamReader.ReadToEnd())!;
53+
ResourceGroup = Instance.Spec.Group;
54+
ResourceVersion = Instance.Spec.Versions.Last().Name;
55+
ResourcePlural = Instance.Spec.Names.Plural;
56+
ResourceKind = Instance.Spec.Names.Kind;
57+
}
58+
59+
/// <summary>
60+
/// Initializes a new <see cref="OperatorResourceDefinition"/>
61+
/// </summary>
62+
public OperatorResourceDefinition() : base(Instance) { }
63+
64+
}

0 commit comments

Comments
 (0)