From afc5c84e0d54667f6a511bdcbe5fbb0a944c17b6 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 14 Jan 2025 17:00:41 +0100 Subject: [PATCH 1/2] fix(Builders): Fix the IContainerProcessDefinitionBuilder and default implementation to allow configuring the container name fix(Builders): Fix the IListenerTargetDefinitionBuilder and default implementation to allow configuring the `until`clause fix(Core): Minor fixes and improvements Signed-off-by: Charles d'Avernas --- .../ContainerProcessDefinitionBuilder.cs | 14 ++++++++ .../IContainerProcessDefinitionBuilder.cs | 7 ++++ .../IListenerTargetDefinitionBuilder.cs | 12 +++++++ .../ListenerTargetDefinitionBuilder.cs | 32 ++++++++++++++++++- .../Models/{Tasks => }/BranchingDefinition.cs | 2 +- .../Models/ForLoopDefinition.cs | 2 +- .../Models/RaiseErrorDefinition.cs | 2 +- 7 files changed, 67 insertions(+), 4 deletions(-) rename src/ServerlessWorkflow.Sdk/Models/{Tasks => }/BranchingDefinition.cs (97%) diff --git a/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs index c157e7d..60355d3 100644 --- a/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs +++ b/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs @@ -28,6 +28,11 @@ public class ContainerProcessDefinitionBuilder /// protected virtual string? Image { get; set; } + /// + /// Gets/sets the name of the container to run + /// + protected virtual string? Name { get; set; } + /// /// Gets/sets the command, if any, to execute on the container /// @@ -56,6 +61,14 @@ public virtual IContainerProcessDefinitionBuilder WithImage(string image) return this; } + /// + public virtual IContainerProcessDefinitionBuilder WithName(string name) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + this.Name = name; + return this; + } + /// public virtual IContainerProcessDefinitionBuilder WithCommand(string command) { @@ -122,6 +135,7 @@ public override ContainerProcessDefinition Build() return new() { Image = this.Image, + Name = this.Name, Command = this.Command, Ports = this.Ports, Volumes = this.Volumes, diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IContainerProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IContainerProcessDefinitionBuilder.cs index afe3ade..112e935 100644 --- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IContainerProcessDefinitionBuilder.cs +++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IContainerProcessDefinitionBuilder.cs @@ -29,6 +29,13 @@ public interface IContainerProcessDefinitionBuilder /// The configured IContainerProcessDefinitionBuilder WithImage(string image); + /// + /// Configures the container to use the specified name + /// + /// The container's name + /// The configured + IContainerProcessDefinitionBuilder WithName(string name); + /// /// Configures the command, if any, to execute on the container /// diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IListenerTargetDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IListenerTargetDefinitionBuilder.cs index 45a558c..ae9ddd2 100644 --- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IListenerTargetDefinitionBuilder.cs +++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IListenerTargetDefinitionBuilder.cs @@ -37,6 +37,18 @@ public interface IListenerTargetDefinitionBuilder /// A new IEventFilterDefinitionBuilder One(); + /// + /// Configures the task to listen to any events until the specified condition expression matches + /// + /// A runtime expression that represents the condition that must match for the task to stop consuming events + void Until(string expression); + + /// + /// Configures the task to listen to any events until the specified events are consumed + /// + /// An used to configure the events to consume for the task to stop consuming events + void Until(Action setup); + /// /// Builds the configured /// diff --git a/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs index 16a1225..6e85dfe 100644 --- a/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs +++ b/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs @@ -35,6 +35,16 @@ public class ListenerTargetDefinitionBuilder /// protected IEventFilterDefinitionBuilder? SingleEvent { get; set; } + /// + /// Gets the runtime expression that represents the condition that must match for the task to stop consuming events + /// + protected string? UntilExpression { get; private set; } + + /// + /// Gets the strategy used to configure the events to consume for the task to stop consuming events + /// + protected EventConsumptionStrategyDefinition? UntilEvents { get; private set; } + /// public virtual IEventFilterDefinitionCollectionBuilder All() { @@ -56,6 +66,24 @@ public virtual IEventFilterDefinitionBuilder One() return this.SingleEvent; } + /// + public virtual void Until(string expression) + { + ArgumentException.ThrowIfNullOrWhiteSpace(expression); + if (this.AnyEvents == null) throw new Exception("The until clause can only be specified when the strategy is used to consume any events"); + this.UntilExpression = expression; + } + + /// + public virtual void Until(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + if (this.AnyEvents == null) throw new Exception("The until clause can only be specified when the strategy is used to consume any events"); + var builder = new ListenerTargetDefinitionBuilder(); + setup(builder); + this.UntilEvents = builder.Build(); + } + /// public virtual EventConsumptionStrategyDefinition Build() { @@ -64,7 +92,9 @@ public virtual EventConsumptionStrategyDefinition Build() { All = this.AllEvents?.Build(), Any = this.AnyEvents?.Build(), - One = this.SingleEvent?.Build() + One = this.SingleEvent?.Build(), + UntilExpression = this.UntilExpression, + Until = this.UntilEvents }; } diff --git a/src/ServerlessWorkflow.Sdk/Models/Tasks/BranchingDefinition.cs b/src/ServerlessWorkflow.Sdk/Models/BranchingDefinition.cs similarity index 97% rename from src/ServerlessWorkflow.Sdk/Models/Tasks/BranchingDefinition.cs rename to src/ServerlessWorkflow.Sdk/Models/BranchingDefinition.cs index b49e1f3..09bd3d0 100644 --- a/src/ServerlessWorkflow.Sdk/Models/Tasks/BranchingDefinition.cs +++ b/src/ServerlessWorkflow.Sdk/Models/BranchingDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace ServerlessWorkflow.Sdk.Models.Tasks; +namespace ServerlessWorkflow.Sdk.Models; /// /// Represents an object used to configure branches to perform concurrently diff --git a/src/ServerlessWorkflow.Sdk/Models/ForLoopDefinition.cs b/src/ServerlessWorkflow.Sdk/Models/ForLoopDefinition.cs index c82e7b1..f548d8b 100644 --- a/src/ServerlessWorkflow.Sdk/Models/ForLoopDefinition.cs +++ b/src/ServerlessWorkflow.Sdk/Models/ForLoopDefinition.cs @@ -20,7 +20,7 @@ namespace ServerlessWorkflow.Sdk.Models; public record ForLoopDefinition { - /// + /// /// Gets/sets the name of the variable that represents each element in the collection during iteration /// [Required] diff --git a/src/ServerlessWorkflow.Sdk/Models/RaiseErrorDefinition.cs b/src/ServerlessWorkflow.Sdk/Models/RaiseErrorDefinition.cs index 825e18c..7a38ef4 100644 --- a/src/ServerlessWorkflow.Sdk/Models/RaiseErrorDefinition.cs +++ b/src/ServerlessWorkflow.Sdk/Models/RaiseErrorDefinition.cs @@ -49,7 +49,7 @@ public virtual string? ErrorReference } /// - /// Gets/sets the endpoint at which to get the defined resource + /// Gets/sets the error to raise /// [Required] [DataMember(Name = "error", Order = 1), JsonInclude, JsonPropertyName("error"), JsonPropertyOrder(1), YamlMember(Alias = "error", Order = 1)] From 093309e7a8803bd47493b4dc045465b034677470 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 14 Jan 2025 17:01:22 +0100 Subject: [PATCH 2/2] fix(Solution): Updated the version of all solution projects to `1.0.0-alpha6.3` Signed-off-by: Charles d'Avernas --- .../ServerlessWorkflow.Sdk.Builders.csproj | 2 +- src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj | 2 +- src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj b/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj index f274db9..91e28bf 100644 --- a/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj +++ b/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj @@ -5,7 +5,7 @@ enable enable 1.0.0 - alpha6.2 + alpha6.3 $(VersionPrefix) $(VersionPrefix) en diff --git a/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj b/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj index 83075ff..a9bbfd2 100644 --- a/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj +++ b/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj @@ -5,7 +5,7 @@ enable enable 1.0.0 - alpha6.2 + alpha6.3 $(VersionPrefix) $(VersionPrefix) en diff --git a/src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj b/src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj index 06e4b71..f4b68a3 100644 --- a/src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj +++ b/src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj @@ -5,7 +5,7 @@ enable enable 1.0.0 - alpha6.2 + alpha6.3 $(VersionPrefix) $(VersionPrefix) en pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy