funflow-1.5.0: Workflows with arrows

Safe HaskellNone
LanguageHaskell2010

Control.Funflow.External.Coordinator

Description

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

Documentation

newtype Executor Source #

Information about an executor capable of running tasks. Currently this is just a newtype wrapper around hostname.

Constructors

Executor HostName 

data TaskStatus Source #

Constructors

Pending

Task is in the queue and has not begun executing

Running ExecutionInfo 
Completed ExecutionInfo 
Failed ExecutionInfo Int

Task has failed with failure count

class Coordinator c where Source #

Associated Types

type Config c Source #

type Hook c = h | h -> c Source #

Methods

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
Coordinator SQLite Source # 
Instance details

Defined in Control.Funflow.External.Coordinator.SQLite

Associated Types

type Config SQLite :: Type Source #

type Hook SQLite = (h :: Type) Source #

Coordinator RedisPreconnected Source #

Allow a preestablished redis connection to be used.

Instance details

Defined in Control.Funflow.External.Coordinator.Redis

Associated Types

type Config RedisPreconnected :: Type Source #

type Hook RedisPreconnected = (h :: Type) Source #

Coordinator Redis Source # 
Instance details

Defined in Control.Funflow.External.Coordinator.Redis

Associated Types

type Config Redis :: Type Source #

type Hook Redis = (h :: Type) Source #

Coordinator MemoryCoordinator Source # 
Instance details

Defined in Control.Funflow.External.Coordinator.Memory

Associated Types

type Config MemoryCoordinator :: Type Source #

type Hook MemoryCoordinator = (h :: Type) 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 Just () on task completion or regular failure.