forked from serverlessworkflow/synapse
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
619 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Synapse; | ||
|
||
/// <summary> | ||
/// Defines extensions for <see cref="WorkflowInstance"/>s | ||
/// </summary> | ||
public static class WorkflowInstanceExtensions | ||
{ | ||
|
||
/// <summary> | ||
/// Determines whether or not the <see cref="WorkflowInstance"/> is managed by the specified <see cref="WorkflowAgent"/> | ||
/// </summary> | ||
/// <param name="instance">The extended <see cref="WorkflowInstance"/></param> | ||
/// <param name="agentQualifiedName">The qualified name of the <see cref="WorkflowAgent"/> to check</param> | ||
/// <returns>A boolean indicating whether or not the <see cref="WorkflowInstance"/> is managed by the specified <see cref="WorkflowAgent"/></returns> | ||
public static bool IsManagedBy(this WorkflowInstance instance, string agentQualifiedName) | ||
{ | ||
if (string.IsNullOrWhiteSpace(agentQualifiedName)) throw new ArgumentNullException(nameof(agentQualifiedName)); | ||
return instance.Metadata.Labels != null && instance.Metadata.Labels.TryGetValue(WorkflowInstance.Labels.Agent, out var agentRef) && agentRef == agentQualifiedName; | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether or not the <see cref="WorkflowInstance"/> is managed by the specified <see cref="WorkflowAgent"/> | ||
/// </summary> | ||
/// <param name="instance">The extended <see cref="WorkflowInstance"/></param> | ||
/// <param name="agent">The <see cref="WorkflowAgent"/> to check</param> | ||
/// <returns>A boolean indicating whether or not the <see cref="WorkflowInstance"/> is managed by the specified <see cref="WorkflowAgent"/></returns> | ||
public static bool IsManagedBy(this WorkflowInstance instance, WorkflowAgent agent) => instance.IsManagedBy(agent.GetQualifiedName()); | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ public enum ProcessPhase | |
/// </summary> | ||
[EnumMember(Value = "exited")] | ||
Exited | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace Synapse.Resources; | ||
|
||
/// <summary> | ||
/// Represents an object used to describe a period of time during which a workflow instance has been running | ||
/// </summary> | ||
public record WorkflowInstanceRuntime | ||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="WorkflowInstanceRuntime"/> | ||
/// </summary> | ||
public WorkflowInstanceRuntime() { } | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="WorkflowInstanceRuntime"/> | ||
/// </summary> | ||
/// <param name="agentQualifiedName">The qualified name of the agent managing the execution of the workflow instance</param> | ||
/// <param name="processId">A value used to globally and uniquely identify the process that is running the workflow instance</param> | ||
public WorkflowInstanceRuntime(string agentQualifiedName, string processId) | ||
{ | ||
if (string.IsNullOrWhiteSpace(agentQualifiedName)) throw new ArgumentNullException(nameof(agentQualifiedName)); | ||
if (string.IsNullOrWhiteSpace(processId)) throw new ArgumentNullException(nameof(processId)); | ||
this.Agent = agentQualifiedName; | ||
this.ProcessId = processId; | ||
this.StartedAt = DateTimeOffset.Now; | ||
} | ||
|
||
/// <summary> | ||
/// Gets/sets the qualified name of the agent managing the execution of the workflow instance | ||
/// </summary> | ||
[Required] | ||
[DataMember(Order = 1, Name = "agent", IsRequired = true), JsonPropertyOrder(1), JsonPropertyName("agent"), YamlMember(Order = 1, Alias = "agent")] | ||
public virtual string Agent { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Gets/sets a value used to globally and uniquely identify the process that is running the workflow instance | ||
/// </summary> | ||
[Required] | ||
[DataMember(Order = 2, Name = "processId", IsRequired = true), JsonPropertyOrder(2), JsonPropertyName("processId"), YamlMember(Order = 2, Alias = "processId")] | ||
public virtual string ProcessId { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Gets the date and time at which the session has started | ||
/// </summary> | ||
[Required] | ||
[DataMember(Order = 3, Name = "startedAt", IsRequired = true), JsonPropertyOrder(3), JsonPropertyName("startedAt"), YamlMember(Order = 3, Alias = "startedAt")] | ||
public virtual DateTimeOffset StartedAt { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the date and time at which the session has ended | ||
/// </summary> | ||
[DataMember(Order = 4, Name = "endedAt"), JsonPropertyOrder(4), JsonPropertyName("endedAt"), YamlMember(Order = 4, Alias = "endedAt")] | ||
public virtual DateTimeOffset? EndedAt { get; set; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Hylo.Serialization.Json; | ||
using Hylo.Serialization; | ||
using System.ComponentModel; | ||
|
||
namespace Synapse; | ||
|
||
/// <summary> | ||
/// Enuemrates the possible phases a workflow instance can go through | ||
/// </summary> | ||
[TypeConverter(typeof(StringEnumTypeConverter))] | ||
[JsonConverter(typeof(JsonStringEnumConverterFactory))] | ||
public enum WorkflowInstancePhase | ||
{ | ||
/// <summary> | ||
/// Indicates that the workflow instance is pending execution | ||
/// </summary> | ||
[EnumMember(Value = "pending")] | ||
Pending, | ||
/// <summary> | ||
/// Indicates that the workflow instance is being executed | ||
/// </summary> | ||
[EnumMember(Value = "running")] | ||
Running, | ||
/// <summary> | ||
/// Indicates that the execution of the workflow instance has been suspended | ||
/// </summary> | ||
[EnumMember(Value = "suspended")] | ||
Suspended, | ||
/// <summary> | ||
/// Indicates that the execution of the workflow instance faulted | ||
/// </summary> | ||
[EnumMember(Value = "faulted")] | ||
Faulted, | ||
/// <summary> | ||
/// Indicates that the execution of the workflow instance has been cancelled | ||
/// </summary> | ||
[EnumMember(Value = "cancelled")] | ||
Cancelled, | ||
/// <summary> | ||
/// Indicates that the execution of the workflow instance completed successfully | ||
/// </summary> | ||
[EnumMember(Value = "completed")] | ||
Completed | ||
} |
Oops, something went wrong.