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 the SubscriptionIteratorDefinition model #77

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace ServerlessWorkflow.Sdk.Builders;

/// <summary>
/// Represents the default implementation of the <see cref="IInputDataModelDefinitionBuilder"/> interface
/// </summary>
public class InputDataModelDefinitionBuilder
: IInputDataModelDefinitionBuilder
{

/// <summary>
/// Gets the <see cref="InputDataModelDefinition"/> to configure
/// </summary>
protected InputDataModelDefinition Input { get; } = new();

/// <inheritdoc/>
public virtual IInputDataModelDefinitionBuilder From(object expression)
{
ArgumentNullException.ThrowIfNull(expression);
this.Input.From = expression;
return this;
}

/// <inheritdoc/>
public virtual IInputDataModelDefinitionBuilder WithSchema(Action<ISchemaDefinitionBuilder> setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new SchemaDefinitionBuilder();
setup(builder);
this.Input.Schema = builder.Build();
return this;
}

/// <inheritdoc/>
public virtual InputDataModelDefinition Build() => this.Input;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace ServerlessWorkflow.Sdk.Builders;

/// <summary>
/// Defines the fundamentals of a service used to build <see cref="InputDataModelDefinition"/>s
/// </summary>
public interface IInputDataModelDefinitionBuilder
{

/// <summary>
/// Configures the input data schema
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the input data schema</param>
/// <returns>The configured <see cref="IInputDataModelDefinitionBuilder"/></returns>
IInputDataModelDefinitionBuilder WithSchema(Action<ISchemaDefinitionBuilder> setup);

/// <summary>
/// Configures the runtime expression used to filter the input data
/// </summary>
/// <param name="expression">The runtime expression used to filter the input data</param>
/// <returns>The configured <see cref="IInputDataModelDefinitionBuilder"/></returns>
IInputDataModelDefinitionBuilder From(object expression);

/// <summary>
/// Builds the configured <see cref="InputDataModelDefinition"/>
/// </summary>
/// <returns>A new <see cref="InputDataModelDefinition"/></returns>
InputDataModelDefinition Build();

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ public interface IListenTaskDefinitionBuilder
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to setup the task's listener target</param>
/// <returns>The configured <see cref="IListenTaskDefinitionBuilder"/></returns>
IListenTaskDefinitionBuilder To(Action<IListenerTargetDefinitionBuilder> setup);
IListenTaskDefinitionBuilder To(Action<IListenerDefinitionBuilder> setup);

/// <summary>
/// Configures the iterator used to process each consumed event
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the <see cref="SubscriptionIteratorDefinition"/> to use</param>
/// <returns>The configured <see cref="IListenTaskDefinitionBuilder"/></returns>
IListenTaskDefinitionBuilder Foreach(Action<ISubscriptionIteratorDefinitionBuilder> setup);

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ namespace ServerlessWorkflow.Sdk.Builders;
/// Defines the fundamentals of a service used to build <see cref="ListenerDefinition"/>s
/// </summary>
public interface IListenerDefinitionBuilder
: IListenerTargetDefinitionBuilder
{

/// <summary>
/// Configures the
/// Configures how to read consumed events
/// </summary>
/// <param name="setup"></param>
/// <returns></returns>
IListenerDefinitionBuilder To(Action<IListenerTargetDefinitionBuilder> setup);
/// <param name="readMode">Specifies how consumed events should be read. See <see cref="EventReadMode"/>s</param>
/// <returns>The configured <see cref="IListenerDefinitionBuilder"/></returns>
IListenerDefinitionBuilder Read(string readMode);

/// <summary>
/// Builds the configured <see cref="ListenerDefinition"/>
/// </summary>
/// <returns>A new <see cref="ListenerDefinition"/></returns>
ListenerDefinition Build();
new ListenerDefinition Build();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace ServerlessWorkflow.Sdk.Builders;

/// <summary>
/// Defines the fundamentals of a service used to build <see cref="OutputDataModelDefinition"/>s
/// </summary>
public interface IOutputDataModelDefinitionBuilder
{

/// <summary>
/// Configures the output data schema
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the output data schema</param>
/// <returns>The configured <see cref="IOutputDataModelDefinitionBuilder"/></returns>
IOutputDataModelDefinitionBuilder WithSchema(Action<ISchemaDefinitionBuilder> setup);

/// <summary>
/// Configures the runtime expression used to filter the data to output
/// </summary>
/// <param name="expression">The runtime expression used to filter the data to output</param>
/// <returns>The configured <see cref="IOutputDataModelDefinitionBuilder"/></returns>
IOutputDataModelDefinitionBuilder As(object expression);

/// <summary>
/// Builds the configured <see cref="OutputDataModelDefinition"/>
/// </summary>
/// <returns>A new <see cref="OutputDataModelDefinition"/></returns>
OutputDataModelDefinition Build();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace ServerlessWorkflow.Sdk.Builders;

/// <summary>
/// Defines the fundamentals of a service used to build <see cref="SchemaDefinition"/>s
/// </summary>
public interface ISchemaDefinitionBuilder
{

/// <summary>
/// Sets the schema format
/// </summary>
/// <param name="format">The schema format</param>
/// <returns>The configured <see cref="ISchemaDefinitionBuilder"/></returns>
ISchemaDefinitionBuilder WithFormat(string format);

/// <summary>
/// Sets the schema's <see cref="ExternalResourceDefinition"/>
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the schema's <see cref="ExternalResourceDefinition"/></param>
/// <returns>The configured <see cref="ISchemaDefinitionBuilder"/></returns>
ISchemaDefinitionBuilder WithResource(Action<IExternalResourceDefinitionBuilder> setup);

/// <summary>
/// Sets the schema document
/// </summary>
/// <param name="document">The schema document</param>
/// <returns>The configured <see cref="ISchemaDefinitionBuilder"/></returns>
ISchemaDefinitionBuilder WithDocument(object document);

/// <summary>
/// Builds the configured <see cref="SchemaDefinition"/>
/// </summary>
/// <returns>A new <see cref="SchemaDefinition"/></returns>
SchemaDefinition Build();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace ServerlessWorkflow.Sdk.Builders;

/// <summary>
/// Defines the fundamentals of a service used to build <see cref="SubscriptionIteratorDefinition"/>s
/// </summary>
public interface ISubscriptionIteratorDefinitionBuilder
{

/// <summary>
/// Sets the name of the variable used to store the item being enumerated
/// </summary>
/// <param name="item">The name of the variable used to store the item being enumerated</param>
/// <returns>The configured <see cref="ISubscriptionIteratorDefinitionBuilder"/></returns>
ISubscriptionIteratorDefinitionBuilder Item(string item);

/// <summary>
/// Sets the name of the variable used to store the index of the item being enumerated
/// </summary>
/// <param name="at">The name of the variable used to store the index of the item being enumerated</param>
/// <returns>The configured <see cref="ISubscriptionIteratorDefinitionBuilder"/></returns>
ISubscriptionIteratorDefinitionBuilder At(string at);

/// <summary>
/// Sets the tasks to execute for each event or message consumed
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the tasks to execute for each event or message consumed</param>
/// <returns>The configured <see cref="ISubscriptionIteratorDefinitionBuilder"/></returns>
ISubscriptionIteratorDefinitionBuilder Do(Action<ITaskDefinitionMapBuilder> setup);

/// <summary>
/// Configures the output data of each item
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the output data</param>
/// <returns>The configured <see cref="ISubscriptionIteratorDefinitionBuilder"/></returns>
ISubscriptionIteratorDefinitionBuilder Output(Action<IOutputDataModelDefinitionBuilder> setup);

/// <summary>
/// Configures the data exported by each item
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the exported data</param>
/// <returns>The configured <see cref="ISubscriptionIteratorDefinitionBuilder"/></returns>
ISubscriptionIteratorDefinitionBuilder Export(Action<IOutputDataModelDefinitionBuilder> setup);

/// <summary>
/// Builds the configured <see cref="SubscriptionIteratorDefinition"/>
/// </summary>
/// <returns>A new <see cref="SubscriptionIteratorDefinition"/></returns>
SubscriptionIteratorDefinition Build();

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,47 @@ public interface ITaskDefinitionBuilder<TBuilder>
TBuilder If(string condition);

/// <summary>
/// Sets the workflow's timeout
/// Sets the task's timeout
/// </summary>
/// <param name="name">The name of the workflow's timeout</param>
/// <param name="name">The name of the task's timeout</param>
/// <returns>The configured <see cref="ITaskDefinitionBuilder{TBuilder}"/></returns>
TBuilder WithTimeout(string name);

/// <summary>
/// Sets the workflow's timeout
/// Sets the task's timeout
/// </summary>
/// <param name="timeout">The workflow's timeout</param>
/// <param name="timeout">The task's timeout</param>
/// <returns>The configured <see cref="ITaskDefinitionBuilder{TBuilder}"/></returns>
TBuilder WithTimeout(TimeoutDefinition timeout);

/// <summary>
/// Sets the workflow's timeout
/// Sets the task's timeout
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to setup the workflow's timeout</param>
/// <param name="setup">An <see cref="Action{T}"/> used to setup the task's timeout</param>
/// <returns>The configured <see cref="ITaskDefinitionBuilder{TBuilder}"/></returns>
TBuilder WithTimeout(Action<ITimeoutDefinitionBuilder> setup);

/// <summary>
/// Sets the task's input data
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the task's input</param>
/// <returns>The configured <see cref="ITaskDefinitionBuilder{TBuilder}"/></returns>
TBuilder WithInput(Action<IInputDataModelDefinitionBuilder> setup);

/// <summary>
/// Sets the task's output data
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the task's output</param>
/// <returns>The configured <see cref="ITaskDefinitionBuilder{TBuilder}"/></returns>
TBuilder WithOutput(Action<IOutputDataModelDefinitionBuilder> setup);

/// <summary>
/// Sets the data exported by the task
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the data exported by the task</param>
/// <returns>The configured <see cref="ITaskDefinitionBuilder{TBuilder}"/></returns>
TBuilder WithExport(Action<IOutputDataModelDefinitionBuilder> setup);

/// <summary>
/// Configures the task to build to then execute the specified flow directive
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ public interface IWorkflowDefinitionBuilder
/// <returns>The configured <see cref="IWorkflowDefinitionBuilder"/></returns>
IWorkflowDefinitionBuilder WithTimeout(Action<ITimeoutDefinitionBuilder> setup);

/// <summary>
/// Sets the workflow's input data
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the workflow's input</param>
/// <returns>The configured <see cref="IWorkflowDefinitionBuilder"/></returns>
IWorkflowDefinitionBuilder WithInput(Action<IInputDataModelDefinitionBuilder> setup);

/// <summary>
/// Sets the workflow's output data
/// </summary>
/// <param name="setup">An <see cref="Action{T}"/> used to configure the workflow's output</param>
/// <returns>The configured <see cref="IWorkflowDefinitionBuilder"/></returns>
IWorkflowDefinitionBuilder WithOutput(Action<IOutputDataModelDefinitionBuilder> setup);

/// <summary>
/// Uses the specified authentication policy
/// </summary>
Expand Down
Loading
Loading