restricted-workers-0.1.1: Running worker processes under system resource restrictions

Safe HaskellNone




Worker can be in one of three states

Uninitialized worker is a worker that has a name, a socket, possibly WData but has not been forker
Initialized worker has an associated forker process.
A worker is active if it's initialized and it's being used a client. Active/inactive workers are managed by a WorkersPool.



data Worker a Source

A datatype representing a worker of type a




workerName :: String

Name of the worker

workerSocket :: FilePath

A filepath to the Unix socket that will be used for communicating with the worker. If the file is already present it will be unliked during the initializatin step

workerLimits :: LimitSettings

Security restrictions for the worker

workerPid :: Maybe ProcessID

'Just pid' if the worker's process ID is pid, Nothing' if the worker is not active/initialized

type RestartWorker m a = Worker a -> m (Worker a)Source

A worker restarting function

class WorkerData w Source

Types of data attached to a worker. This might be a configuration file, a size of the packet, session data, etc.

Associated Types

type WData w :: *Source

Data that saves after restarts

type WMonad w :: * -> *Source

Monad in which the worker runs


data IOWorker Source

A simple type of worker that executes IO actions

The definition of the WorkerData instance for IOWorker looks like this:

  instance WorkerData IOWorker where
      type WData IOWorker = ()
      type WMonad IOWorker = IO


Other types

data ProtocolException Source

An exception type used by Protocol


ConversionException String

There has been an error during the conversion step

HandleException IOException

There has been an error while using the handler

Helper functions

initialized :: Worker a -> BoolSource

Check whether the worker is initialized