Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Distributed.Fork.Backend
Description
You only need this module if you want to create a new backend for distributed-dataset.
Synopsis
- newtype Backend = Backend {
- bExecute :: ByteString -> BackendM ByteString
- data BackendM a
- argExecutorMode :: String
- data ExecutorFinalStatus a
- data ExecutorStatus a
- data ExecutorPendingStatus
- waiting :: BackendM ()
- waitingDesc :: Text -> BackendM ()
- submitted :: BackendM ()
- submittedDesc :: Text -> BackendM ()
- started :: BackendM ()
- startedDesc :: Text -> BackendM ()
- throttledBackend :: MonadIO m => Int -> Backend -> m Backend
- runBackend :: Closure (Dict (Serializable i)) -> Closure (IO i) -> Backend -> IO (Handle i)
- toBackendStdin :: Closure (Dict (Serializable a)) -> Closure (IO a) -> ByteString
- fromBackendStdout :: Binary a => ByteString -> ExecutorFinalStatus a
- liftIO :: MonadIO m => IO a -> m a
- getExecutablePath :: IO FilePath
Writing a Backend
.
Backend
is responsible for running your functions in a remote environment.
Should run the current binary in the target environment, put the given
string as standard input and return the executables answer on the standard
output.
|
BackendM is essentially IO
, but also has the ability to report the status of the
executor.
Constructors
Backend | |
Fields
|
Instances
Monad BackendM Source # | |
Functor BackendM Source # | |
Applicative BackendM Source # | |
Defined in Control.Distributed.Fork.Internal | |
MonadIO BackendM Source # | |
MonadUnliftIO BackendM Source # | |
Defined in Control.Distributed.Fork.Internal | |
MonadThrow BackendM Source # | |
MonadCatch BackendM Source # | |
MonadMask BackendM Source # | |
Defined in Control.Distributed.Fork.Internal Methods mask :: ((forall a. BackendM a -> BackendM a) -> BackendM b) -> BackendM b Source # uninterruptibleMask :: ((forall a. BackendM a -> BackendM a) -> BackendM b) -> BackendM b Source # generalBracket :: BackendM a -> (a -> ExitCase b -> BackendM c) -> (a -> BackendM b) -> BackendM (b, c) Source # |
argExecutorMode :: String Source #
We switch to executor mode only when argv[1] == argExecutorMode
.
Reporting status
data ExecutorFinalStatus a Source #
Constructors
ExecutorFailed Text | |
ExecutorSucceeded a |
Instances
data ExecutorStatus a Source #
Constructors
ExecutorPending ExecutorPendingStatus | |
ExecutorFinished (ExecutorFinalStatus a) |
Instances
Functor ExecutorStatus Source # | |
Defined in Control.Distributed.Fork.Internal Methods fmap :: (a -> b) -> ExecutorStatus a -> ExecutorStatus b Source # (<$) :: a -> ExecutorStatus b -> ExecutorStatus a Source # | |
Eq a => Eq (ExecutorStatus a) Source # | |
Defined in Control.Distributed.Fork.Internal Methods (==) :: ExecutorStatus a -> ExecutorStatus a -> Bool Source # (/=) :: ExecutorStatus a -> ExecutorStatus a -> Bool Source # |
data ExecutorPendingStatus Source #
Constructors
ExecutorWaiting (Maybe Text) | |
ExecutorSubmitted (Maybe Text) | |
ExecutorStarted (Maybe Text) |
Instances
Eq ExecutorPendingStatus Source # | |
Defined in Control.Distributed.Fork.Internal Methods (==) :: ExecutorPendingStatus -> ExecutorPendingStatus -> Bool Source # (/=) :: ExecutorPendingStatus -> ExecutorPendingStatus -> Bool Source # |
waitingDesc :: Text -> BackendM () Source #
submittedDesc :: Text -> BackendM () Source #
startedDesc :: Text -> BackendM () Source #
Utils
runBackend :: Closure (Dict (Serializable i)) -> Closure (IO i) -> Backend -> IO (Handle i) Source #
Given an IO action and a static proof that the result is Serializable
, this
function runs the action using the Backend in a separate thread and returns a
TVar
holding the ExecutorStatus
.
toBackendStdin :: Closure (Dict (Serializable a)) -> Closure (IO a) -> ByteString Source #
fromBackendStdout :: Binary a => ByteString -> ExecutorFinalStatus a Source #
Re-exports
getExecutablePath :: IO FilePath Source #
Returns the absolute pathname of the current executable.
Note that for scripts and interactive sessions, this is the path to the interpreter (e.g. ghci.)
Since base 4.11.0.0, getExecutablePath
resolves symlinks on Windows.
If an executable is launched through a symlink, getExecutablePath
returns the absolute path of the original executable.
Since: base-4.6.0.0