Copyright | (c) Anton Gushcha (ncrashed) 2020 |
---|---|
License | MIT |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | Portable |
Safe Haskell | None |
Language | Haskell2010 |
Here is a longer description of this module, containing some
commentary with some markup
.
Typical usage:
worker "supervisor" $ const $ forever $ do logInfoN "Supervisor started" let subworkers = [ subworker1 , subworker2 ] traverse_ (isolate_ "subworker") subworkers liftIO $ threadDelay 10_000_000
Synopsis
- workerWith :: (MonadUnliftIO m, MonadLogger m) => (String -> SomeException -> m ()) -> String -> (Thread -> m ()) -> m Thread
- worker :: (MonadUnliftIO m, MonadLogger m) => String -> (Thread -> m ()) -> m Thread
- isolate :: (MonadUnliftIO m, MonadLogger m, NFData a) => String -> a -> m a -> m a
- isolate_ :: (MonadUnliftIO m, MonadLogger m) => String -> m () -> m ()
Documentation
:: (MonadUnliftIO m, MonadLogger m) | |
=> (String -> SomeException -> m ()) | Action to perform before worker restart |
-> String | Worker label for thred |
-> (Thread -> m ()) | Worker action (no looping is added) |
-> m Thread |
Start immortal worker that logs on exceptions and restarts.
Note that action is not looped implicitly. Add forever
into action
manually to achive this.
worker :: (MonadUnliftIO m, MonadLogger m) => String -> (Thread -> m ()) -> m Thread Source #
Helper that starts new immortal thread with logging of errors
isolate :: (MonadUnliftIO m, MonadLogger m, NFData a) => String -> a -> m a -> m a Source #
If computation fails, print log and return default value.
isolate_ :: (MonadUnliftIO m, MonadLogger m) => String -> m () -> m () Source #
Same as isolate
but returns empty tuple