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)]