internal WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, WorkflowManagementId identifier, IEnumerable <TaskType> typesProcessed, ILua lua, EventHandler <Exception> exceptionHandler = null, Behaviours behaviours = Behaviours.All) { _taskHandler = taskHandler; _workflowHandler = workflowHandler; if (exceptionHandler != null) { ExceptionThrown += exceptionHandler; } _typesProcessed = typesProcessed; _db = mux.GetDatabase(); _sub = mux.GetSubscriber(); if (_typesProcessed == null || _typesProcessed.Count() == 0) { _sub.Subscribe("submittedTask", (c, v) => { ProcessNextTask(); }); } else { foreach (var t in _typesProcessed.Select(ty => ty.ToString())) { _sub.Subscribe("submittedTask:" + t, (c, v) => { ProcessNextTask(t); }); } } _sub.Subscribe("workflowFailed", (c, v) => { ProcessNextFailedWorkflow(); }); _sub.Subscribe("workflowComplete", (c, v) => { ProcessNextCompleteWorkflow(); }); _lua = lua; _lua.LoadScripts(_db, mux.GetServer("localhost:6379")); _identifier = identifier; if (behaviours.HasFlag(Behaviours.AutoRestart)) { var resubmittedTasks = ResubmitTasks(); foreach (var item in resubmittedTasks) { Console.WriteLine("Resubmitted {0}", item); } } }
internal WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, WorkflowManagementId identifier, IEnumerable<TaskType> typesProcessed, ILua lua, EventHandler<Exception> exceptionHandler = null, Behaviours behaviours = Behaviours.All) { _taskHandler = taskHandler; _workflowHandler = workflowHandler; if (exceptionHandler != null) { ExceptionThrown += exceptionHandler; } _typesProcessed = typesProcessed; _db = mux.GetDatabase(); _sub = mux.GetSubscriber(); if (_typesProcessed == null || _typesProcessed.Count() == 0) { _sub.Subscribe("submittedTask", (c, v) => { ProcessNextTask(); }); } else { foreach(var t in _typesProcessed.Select(ty => ty.ToString())) { _sub.Subscribe("submittedTask:" + t, (c, v) => { ProcessNextTask(t); }); } } _sub.Subscribe("workflowFailed", (c, v) => { ProcessNextFailedWorkflow(); }); _sub.Subscribe("workflowComplete", (c, v) => { ProcessNextCompleteWorkflow(); }); _lua = lua; _lua.LoadScripts(_db, mux.GetServer("localhost:6379")); _identifier = identifier; if (behaviours.HasFlag(Behaviours.AutoRestart)) { var resubmittedTasks = ResubmitTasks(); foreach (var item in resubmittedTasks) { Console.WriteLine("Resubmitted {0}", item); } } }
/// <summary> /// Instantiate a new workflow manager, able to submit workflows and process tasks. /// </summary> /// <param name="mux"></param> /// <param name="taskHandler"></param> /// <param name="workflowHandler"></param> /// <param name="identifier"></param> /// <param name="exceptionHandler"></param> /// <param name="lowestPriority"> /// The lowest priority task this instance will consider. High priority is given a score of 0; lowest priority should be given /// a score > 0. Defaults to 100. Note that you should have at least one instance able to cover the whole priority range you /// submit at. /// </param> /// <param name="typesProcessed"></param> /// <param name="behaviours"></param> public WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, WorkflowManagementId identifier, EventHandler <Exception> exceptionHandler, int lowestPriority = 100, IEnumerable <TaskType> typesProcessed = null, Behaviours behaviours = Behaviours.All) : this(mux, taskHandler, workflowHandler, identifier, typesProcessed, new Lua(lowestPriority), exceptionHandler, behaviours) { }
/// <summary> /// Instantiate a new workflow manager, able to submit workflows and process tasks. /// </summary> /// <param name="mux"></param> /// <param name="taskHandler"></param> /// <param name="workflowHandler"></param> /// <param name="identifier"></param> /// <param name="exceptionHandler"></param> /// <param name="lowestPriority"> /// The lowest priority task this instance will consider. High priority is given a score of 0; lowest priority should be given /// a score > 0. Defaults to 100. Note that you should have at least one instance able to cover the whole priority range you /// submit at. /// </param> /// <param name="typesProcessed"></param> /// <param name="behaviours"></param> public WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, WorkflowManagementId identifier, EventHandler<Exception> exceptionHandler, int lowestPriority = 100, IEnumerable<TaskType> typesProcessed = null, Behaviours behaviours = Behaviours.All) : this(mux, taskHandler, workflowHandler, identifier, typesProcessed, new Lua(lowestPriority), exceptionHandler, behaviours) { }