Safe Haskell | None |
---|---|
Language | Haskell2010 |
A Funflow coordinator is used to distribute tasks amongst multiple executors. It provides a functionality to submit tasks, to fetch them for execution, and to check on their status.
There are multiple possible instantiations of the Coordinator
class.
Synopsis
- newtype Executor = Executor HostName
- data TaskStatus
- data TaskInfo
- data ExecutionInfo = ExecutionInfo {}
- data TaskError = ExternalTaskFailed TaskDescription TaskInfo (Maybe (Path Abs File)) (Maybe (Path Abs File))
- class Coordinator c where
- type Config c
- type Hook c = h | h -> c
- initialise :: MonadIO m => Config c -> m (Hook c)
- submitTask :: MonadIO m => Hook c -> TaskDescription -> m ()
- queueSize :: MonadIO m => Hook c -> m Int
- taskInfo :: MonadIO m => Hook c -> ContentHash -> m TaskInfo
- popTask :: MonadIO m => Hook c -> Executor -> m (Maybe TaskDescription)
- awaitTask :: MonadIO m => Hook c -> ContentHash -> m TaskInfo
- updateTaskStatus :: MonadIO m => Hook c -> ContentHash -> TaskStatus -> m ()
- dropTasks :: MonadIO m => Hook c -> m ()
- eiExecutor :: Lens' ExecutionInfo Executor
- eiElapsed :: Lens' ExecutionInfo TimeSpec
- startTask :: (Coordinator c, MonadIO m) => Hook c -> m (Maybe TaskDescription)
- isInProgress :: (Coordinator c, MonadIO m) => Hook c -> ContentHash -> m Bool
- withPopTask :: (Coordinator c, MonadIO m, MonadMask m, KatipContext m) => Hook c -> Executor -> (TaskDescription -> m (TimeSpec, Either Int ())) -> m (Maybe ())
Documentation
Information about an executor capable of running tasks. Currently this is just a newtype wrapper around hostname.
data TaskStatus Source #
Pending | Task is in the queue and has not begun executing |
Running ExecutionInfo | |
Completed ExecutionInfo | |
Failed ExecutionInfo Int | Task has failed with failure count |
Instances
Show TaskStatus Source # | |
Defined in Control.Funflow.External.Coordinator showsPrec :: Int -> TaskStatus -> ShowS # show :: TaskStatus -> String # showList :: [TaskStatus] -> ShowS # | |
Store TaskStatus Source # | |
Defined in Control.Funflow.External.Coordinator |
data ExecutionInfo Source #
Instances
Show ExecutionInfo Source # | |
Defined in Control.Funflow.External.Coordinator showsPrec :: Int -> ExecutionInfo -> ShowS # show :: ExecutionInfo -> String # showList :: [ExecutionInfo] -> ShowS # | |
Store ExecutionInfo Source # | |
Defined in Control.Funflow.External.Coordinator |
Instances
Show TaskError Source # | |
Exception TaskError Source # | |
Defined in Control.Funflow.External.Coordinator toException :: TaskError -> SomeException # fromException :: SomeException -> Maybe TaskError # displayException :: TaskError -> String # |
class Coordinator c where Source #
initialise :: MonadIO m => Config c -> m (Hook c) Source #
Perform any necessary initialisation to connect to the coordinator.
submitTask :: MonadIO m => Hook c -> TaskDescription -> m () Source #
Submit a task to the task queue. It is allowed to overwrite a known task.
queueSize :: MonadIO m => Hook c -> m Int Source #
View the size of the current task queue
taskInfo :: MonadIO m => Hook c -> ContentHash -> m TaskInfo Source #
Fetch information on the current task
popTask :: MonadIO m => Hook c -> Executor -> m (Maybe TaskDescription) Source #
Pop a task off of the queue for execution. The popped task should be added to the execution queue
awaitTask :: MonadIO m => Hook c -> ContentHash -> m TaskInfo Source #
Await task completion.
If the task is complete, this will return 'KnownTask Completed'.
If the task is failed, this will return 'KnownTask Failed'.
If the task is not known to the system, this will return UnknownTask
.
Otherwise (if the task is pending or running), this will block until
the task either completes or fails.
updateTaskStatus :: MonadIO m => Hook c -> ContentHash -> TaskStatus -> m () Source #
Update execution status for a running task. This should error for a task which is not running.
dropTasks :: MonadIO m => Hook c -> m () Source #
Remove all pending tasks from the queue.
Instances
startTask :: (Coordinator c, MonadIO m) => Hook c -> m (Maybe TaskDescription) Source #
isInProgress :: (Coordinator c, MonadIO m) => Hook c -> ContentHash -> m Bool Source #
Check if a task is currently 'in progress' - e.g. pending or running.
withPopTask :: (Coordinator c, MonadIO m, MonadMask m, KatipContext m) => Hook c -> Executor -> (TaskDescription -> m (TimeSpec, Either Int ())) -> m (Maybe ()) Source #
Pop a task off of the queue for execution. Passes the popped task to the
given function for execution. If the function returns success (Right
),
then the task will be marked as completed in the given time. If the
function returns failure (Left
), then the task will be marked as
failed. If the function raises an exception or is interrupted by an
asynchronous exception, then the task will be placed back on the task
queue and the exception propagated. Returns Nothing
if no task is
available and
on task completion or regular failure.Just
()