/// <summary> /// Initializes a new orchestrator /// </summary> /// <param name="context">The orchestation context</param> public CommandOrchestrator(IApplicationContext context, ICommandExecutionService <TSpec, TPayload> CommandPattern, CommandOrchestrationSettings Settings) : base(context) { this.CommandPattern = CommandPattern; this.cts = new CancellationTokenSource(); this.ct = cts.Token; this.Settings = Settings; }
public void Start(Type SpecType, CommandOrchestrationSettings Settings) { try { Orchestrators.GetOrAdd(SpecType, t => GetOrchestrator(t, Settings ?? DefaultCommandSettings)); } catch (Exception e) { Notify(OrchestrationStartError(SpecType, e)); } }
public void Start(ICommandExecutionService pattern, CommandOrchestrationSettings Settings) { try { Orchestrators.GetOrAdd(pattern.SpecType, _ => GetOrchestrator(pattern, Settings ?? DefaultCommandSettings)); } catch (Exception e) { Notify(OrchestrationStartError(pattern.SpecType, e)); } }
ICommandOrchestrator GetOrchestrator(Type SpecType, CommandOrchestrationSettings Settings) { var orchestrator = C.CPS().Orchestrator(SpecType, true, Settings); return(orchestrator.Require());; }
ICommandOrchestrator GetOrchestrator(ICommandExecutionService pattern, CommandOrchestrationSettings Settings) { var orchestrator = C.CPS().Orchestrator(pattern, true, Settings); return(orchestrator.Require());; }
public CommandOrchestrationController(IApplicationContext context) : base(context) { DefaultCommandSettings = context.Settings <CommandOrchestrationSettings>(); }
ICommandOrchestrator <TSpec, TPayload> CreateOrchestration <TSpec, TPayload> (ICommandExecutionService <TSpec, TPayload> pattern, CommandOrchestrationSettings settings) where TSpec : CommandSpec <TSpec, TPayload>, new() => new CommandOrchestrator <TSpec, TPayload>(Context, pattern, settings);
public Option <ICommandOrchestrator> Orchestrator(Type SpecType, bool start, CommandOrchestrationSettings settings) => from p in Pattern(SpecType) from o in Orchestrator(p, start, settings) select o;
public Option <ICommandOrchestrator> Orchestrator(ICommandExecutionService pattern, bool start, CommandOrchestrationSettings settings) => Try(() => { var orcType = typeof(CommandOrchestrator <,>).MakeGenericType(pattern.SpecType, pattern.PayloadType); return(some((ICommandOrchestrator)Activator.CreateInstance(orcType, Context, pattern, settings)).OnSome(o => { if (start) { o.Start(); } })); });
Option <ICommandOrchestrator <TSpec, TPayload> > ICommandPatternSystem.Orchestrator <TSpec, TPayload>(bool start, CommandOrchestrationSettings settings) => Try(() => { var orchestrator = from p in Pattern <TSpec, TPayload>() let s = settings ?? Context.Settings <CommandOrchestrationSettings>() let manager = CreateOrchestration(p, settings) select manager; return(start ? orchestrator.OnSome(o => o.Start()) : orchestrator); });