-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from delegateas/tst/job-status
Tst/job status
- Loading branch information
Showing
16 changed files
with
252 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace WorkflowEngine.Core | ||
{ | ||
public class ActionCompletedEvent : Event | ||
{ | ||
public override EventType EventType => EventType.ActionCompleted; | ||
|
||
[JsonProperty("jobId")] | ||
public string JobId { get; set; } | ||
[JsonProperty("actionKey")] | ||
public string ActionKey { get; set; } | ||
[JsonProperty("resultPath")] | ||
public string ResultPath { get; set; } | ||
|
||
[JsonProperty("status")] | ||
public string Status { get; set; } | ||
|
||
public static ActionCompletedEvent FromAction(IActionResult result,IAction action,string jobId) | ||
{ | ||
|
||
return new ActionCompletedEvent | ||
{ | ||
|
||
JobId = jobId, | ||
ActionKey = action.Key, | ||
Status = result.Status, | ||
}; | ||
} | ||
} | ||
} |
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,48 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
|
||
namespace WorkflowEngine.Core | ||
{ | ||
public interface IHaveFinisningStatus | ||
{ | ||
IActionResult Result { get; } | ||
} | ||
[JsonConverter(typeof(BaseClassConverter))] | ||
public abstract class Event | ||
{ | ||
[JsonProperty("eventType")] | ||
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))] | ||
public abstract EventType EventType { get; } | ||
|
||
|
||
} | ||
|
||
public class BaseClassConverter : CustomCreationConverter<Event> | ||
{ | ||
private EventType _currentObjectType; | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
var jobj = JObject.ReadFrom(reader); | ||
_currentObjectType = jobj["eventType"].ToObject<EventType>(); | ||
return base.ReadJson(jobj.CreateReader(), objectType, existingValue, serializer); | ||
} | ||
|
||
public override Event Create(Type objectType) | ||
{ | ||
switch (_currentObjectType) | ||
{ | ||
case EventType.ActionCompleted: | ||
return new ActionCompletedEvent(); | ||
case EventType.WorkflowStarted: | ||
return new WorkflowStarteddEvent(); | ||
case EventType.WorkflowFinished: | ||
return new WorkflowFinishedEvent(); | ||
default: | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
} |
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,15 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System.Runtime.Serialization; | ||
|
||
namespace WorkflowEngine.Core | ||
{ | ||
public enum EventType | ||
{ | ||
[EnumMember(Value = "workflow_started")] | ||
WorkflowStarted = 0, | ||
[EnumMember(Value = "workflow_finished")] | ||
WorkflowFinished = 1, | ||
[EnumMember(Value = "action_completed")] | ||
ActionCompleted = 2 | ||
} | ||
} |
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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
using System; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace WorkflowEngine.Core | ||
{ | ||
public interface IOutputsRepository | ||
{ | ||
ValueTask AddAsync(IRunContext context, IWorkflow workflow, IAction action, IActionResult result); | ||
ValueTask AddAsync(IRunContext context, IWorkflow workflow, ITrigger trigger); | ||
ValueTask AddTrigger(ITriggerContext context, IWorkflow workflow, ITrigger trigger); | ||
ValueTask<object> GetTriggerData(Guid id); | ||
ValueTask AddInput(IRunContext context, IWorkflow workflow, IAction action); | ||
ValueTask<object> GetOutputData(Guid id, string v); | ||
ValueTask AddArrayItemAsync(IRunContext run, IWorkflow workflow, string key, IActionResult result); | ||
ValueTask AddArrayInput(IRunContext context, IWorkflow workflow, IAction action); | ||
ValueTask StartScope(IRunContext context, IWorkflow workflow, IAction action); | ||
// ValueTask StartScope(IRunContext context, IWorkflow workflow, IAction action); | ||
ValueTask AddScopeItem(IRunContext context, IWorkflow workflow, IAction action, IActionResult result); | ||
ValueTask EndScope(IRunContext run, IWorkflow workflow, IAction action); | ||
ValueTask AddEvent(IRunContext run, IWorkflow workflow, IAction action, Event @event); | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.