Safe Haskell | None |
---|---|
Language | Haskell2010 |
Concurrent, communicating processes, executed using a single-threaded
scheduler, with support for IO
and Logs
.
This module re-exports most of the library.
There are several scheduler implementations to choose from.
This module re-exports the impure parts of Control.Eff.Concurrent.Process.SingleThreadedScheduler.
To use another scheduler implementation, don't import this module, but instead import one of:
Since: 0.25.0
Synopsis
- newtype Facility = Facility {
- fromFacility :: Int
- data Severity
- data SdParameter = MkSdParameter !Text !Text
- data StructuredDataElement = SdElement {
- _sdElementId :: !Text
- _sdElementParameters :: ![SdParameter]
- data LogMessage = MkLogMessage {}
- emergencySeverity :: Severity
- alertSeverity :: Severity
- criticalSeverity :: Severity
- errorSeverity :: Severity
- warningSeverity :: Severity
- noticeSeverity :: Severity
- informationalSeverity :: Severity
- debugSeverity :: Severity
- kernelMessages :: Facility
- userLevelMessages :: Facility
- mailSystem :: Facility
- systemDaemons :: Facility
- securityAuthorizationMessages4 :: Facility
- linePrinterSubsystem :: Facility
- networkNewsSubsystem :: Facility
- uucpSubsystem :: Facility
- clockDaemon :: Facility
- securityAuthorizationMessages10 :: Facility
- ftpDaemon :: Facility
- ntpSubsystem :: Facility
- logAuditFacility :: Facility
- logAlertFacility :: Facility
- clockDaemon2 :: Facility
- local0 :: Facility
- local1 :: Facility
- local2 :: Facility
- local3 :: Facility
- local4 :: Facility
- local5 :: Facility
- local6 :: Facility
- local7 :: Facility
- sdElementId :: Functor f => (Text -> f Text) -> StructuredDataElement -> f StructuredDataElement
- sdElementParameters :: Functor f => ([SdParameter] -> f [SdParameter]) -> StructuredDataElement -> f StructuredDataElement
- type LogPredicate = LogMessage -> Bool
- class ToLogMessage a where
- toLogMessage :: a -> LogMessage
- lmAppName :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmFacility :: Functor f => (Facility -> f Facility) -> LogMessage -> f LogMessage
- lmHostname :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmMessage :: Functor f => (Text -> f Text) -> LogMessage -> f LogMessage
- lmMessageId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmProcessId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage
- lmSeverity :: Functor f => (Severity -> f Severity) -> LogMessage -> f LogMessage
- lmSrcLoc :: Functor f => (Maybe SrcLoc -> f (Maybe SrcLoc)) -> LogMessage -> f LogMessage
- lmStructuredData :: Functor f => ([StructuredDataElement] -> f [StructuredDataElement]) -> LogMessage -> f LogMessage
- lmThreadId :: Functor f => (Maybe ThreadId -> f (Maybe ThreadId)) -> LogMessage -> f LogMessage
- lmTimestamp :: Functor f => (Maybe UTCTime -> f (Maybe UTCTime)) -> LogMessage -> f LogMessage
- setCallStack :: CallStack -> LogMessage -> LogMessage
- prefixLogMessagesWith :: Text -> LogMessage -> LogMessage
- setLogMessageTimestamp :: LogMessage -> IO LogMessage
- setLogMessageThreadId :: LogMessage -> IO LogMessage
- setLogMessageHostname :: LogMessage -> IO LogMessage
- errorMessage :: HasCallStack => Text -> LogMessage
- infoMessage :: HasCallStack => Text -> LogMessage
- debugMessage :: HasCallStack => Text -> LogMessage
- errorMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage
- infoMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage
- debugMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage
- allLogMessages :: LogPredicate
- noLogMessages :: LogPredicate
- lmSeverityIs :: Severity -> LogPredicate
- lmSeverityIsAtLeast :: Severity -> LogPredicate
- lmMessageStartsWith :: Text -> LogPredicate
- discriminateByAppName :: Text -> LogPredicate -> LogPredicate -> LogPredicate
- data LogMessageTimeRenderer
- type LogMessageRenderer a = LogMessage -> a
- mkLogMessageTimeRenderer :: String -> LogMessageTimeRenderer
- suppressTimestamp :: LogMessageTimeRenderer
- rfc3164Timestamp :: LogMessageTimeRenderer
- rfc5424Timestamp :: LogMessageTimeRenderer
- rfc5424NoZTimestamp :: LogMessageTimeRenderer
- renderLogMessageBody :: LogMessageRenderer Text
- renderLogMessageBodyNoLocation :: LogMessageRenderer Text
- renderLogMessageBodyFixWidth :: LogMessageRenderer Text
- renderMaybeLogMessageLens :: Text -> Getter LogMessage (Maybe Text) -> LogMessageRenderer Text
- renderLogMessageSrcLoc :: LogMessageRenderer (Maybe Text)
- renderSyslogSeverityAndFacility :: LogMessageRenderer Text
- renderLogMessageSyslog :: LogMessageRenderer Text
- renderLogMessageConsoleLog :: LogMessageRenderer Text
- renderRFC3164 :: LogMessageRenderer Text
- renderRFC3164WithRFC5424Timestamps :: LogMessageRenderer Text
- renderRFC3164WithTimestamp :: LogMessageTimeRenderer -> LogMessageRenderer Text
- renderRFC5424 :: LogMessageRenderer Text
- renderRFC5424NoLocation :: LogMessageRenderer Text
- renderRFC5424Header :: LogMessageRenderer Text
- class HandleLogWriter (writer :: Type -> Type) where
- data LogWriterM writer a
- handleLogWriterEffect :: Member writer e => LogWriterM writer () -> Eff e ()
- liftWriteLogMessage :: (SetMember LogWriterReader (LogWriterReader writer) e, Member writer e) => LogMessage -> Eff e ()
- data LogWriterReader h v
- newtype LogWriter writerM = MkLogWriter {
- runLogWriter :: LogMessage -> LogWriterM writerM ()
- runLogWriterReader :: LogWriter h -> Eff (LogWriterReader h ': e) a -> Eff e a
- askLogWriter :: SetMember LogWriterReader (LogWriterReader h) e => Eff e (LogWriter h)
- localLogWriterReader :: forall h e a. SetMember LogWriterReader (LogWriterReader h) e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a
- noOpLogWriter :: Applicative (LogWriterM m) => LogWriter m
- filteringLogWriter :: Monad (LogWriterM e) => LogPredicate -> LogWriter e -> LogWriter e
- mappingLogWriter :: (LogMessage -> LogMessage) -> LogWriter e -> LogWriter e
- mappingLogWriterM :: Monad (LogWriterM e) => (LogMessage -> LogWriterM e LogMessage) -> LogWriter e -> LogWriter e
- type LogIo e = (LogsTo (Lift IO) e, Lifted IO e)
- type LogsTo h e = (Member Logs e, HandleLogWriter h, Member h e, SetMember LogWriterReader (LogWriterReader h) e)
- data Logs v
- withLogging :: forall h e a. (Applicative (LogWriterM h), LogsTo h (Logs ': (LogWriterReader h ': e))) => LogWriter h -> Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a
- withSomeLogging :: forall h e a. (Applicative (LogWriterM h), LogsTo h (Logs ': (LogWriterReader h ': e))) => Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a
- runLogs :: forall h e b. LogsTo h (Logs ': e) => LogPredicate -> Eff (Logs ': e) b -> Eff e b
- logMsg :: forall e. (HasCallStack, Member Logs e) => LogMessage -> Eff e ()
- logWithSeverity :: forall e. (HasCallStack, Member Logs e) => Severity -> Text -> Eff e ()
- logWithSeverity' :: forall e. (HasCallStack, Member Logs e) => Severity -> String -> Eff e ()
- logEmergency :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logAlert :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logCritical :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logError :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logWarning :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logNotice :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logInfo :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logDebug :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e ()
- logEmergency' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logAlert' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logCritical' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logError' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logWarning' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logNotice' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logInfo' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- logDebug' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e ()
- askLogPredicate :: forall e. Member Logs e => Eff e LogPredicate
- setLogPredicate :: forall r b. (Member Logs r, HasCallStack) => LogPredicate -> Eff r b -> Eff r b
- modifyLogPredicate :: forall e b. (Member Logs e, HasCallStack) => (LogPredicate -> LogPredicate) -> Eff e b -> Eff e b
- includeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a
- excludeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a
- respondToLogMessage :: forall r b. Member Logs r => (LogMessage -> Eff r ()) -> Eff r b -> Eff r b
- interceptLogMessages :: forall r b. Member Logs r => (LogMessage -> Eff r LogMessage) -> Eff r b -> Eff r b
- modifyLogWriter :: forall h e a. LogsTo h e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a
- setLogWriter :: forall h e a. LogsTo h e => LogWriter h -> Eff e a -> Eff e a
- censorLogs :: LogsTo h e => (LogMessage -> LogMessage) -> Eff e a -> Eff e a
- censorLogsM :: (LogsTo h e, Monad (LogWriterM h)) => (LogMessage -> LogWriterM h LogMessage) -> Eff e a -> Eff e a
- addLogWriter :: forall h e a. (HasCallStack, LogsTo h e, Monad (LogWriterM h)) => LogWriter h -> Eff e a -> Eff e a
- newtype ProcessId = ProcessId {}
- data ProcessDown = ProcessDown {}
- data MonitorReference = MonitorReference {}
- data SomeExitReason where
- SomeExitReason :: Interrupt x -> SomeExitReason
- type Interrupts = Exc (Interrupt Recoverable)
- type HasSafeProcesses e inner = SetMember Process (Process inner) e
- type SafeProcesses r = Process r ': r
- type HasProcesses e inner = (HasSafeProcesses e inner, Member Interrupts e)
- type Processes e = Interrupts ': SafeProcesses e
- type RecoverableInterrupt = Interrupt Recoverable
- data Interrupt (t :: ExitRecovery) where
- NormalExitRequested :: Interrupt Recoverable
- OtherProcessNotRunning :: ProcessId -> Interrupt Recoverable
- TimeoutInterrupt :: String -> Interrupt Recoverable
- LinkedProcessCrashed :: ProcessId -> Interrupt Recoverable
- ErrorInterrupt :: String -> Interrupt Recoverable
- ExitNormally :: Interrupt NoRecovery
- ExitUnhandledError :: Text -> Interrupt NoRecovery
- ExitProcessCancelled :: Interrupt NoRecovery
- data ExitSeverity
- = NormalExit
- | Crash
- data ExitRecovery
- data MessageSelector a
- data ResumeProcess v where
- Interrupted :: Interrupt Recoverable -> ResumeProcess v
- ResumeWith :: a -> ResumeProcess a
- newtype Serializer message = MkSerializer {
- runSerializer :: message -> StrictDynamic
- data StrictDynamic
- newtype ProcessDetails = MkProcessDetails {}
- newtype ProcessTitle = MkProcessTitle {}
- data Process (r :: [Type -> Type]) b where
- FlushMessages :: Process r (ResumeProcess [StrictDynamic])
- YieldProcess :: Process r (ResumeProcess ())
- SelfPid :: Process r (ResumeProcess ProcessId)
- Spawn :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId)
- SpawnLink :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId)
- Shutdown :: Interrupt NoRecovery -> Process r a
- SendShutdown :: ProcessId -> Interrupt NoRecovery -> Process r (ResumeProcess ())
- SendInterrupt :: ProcessId -> Interrupt Recoverable -> Process r (ResumeProcess ())
- SendMessage :: ProcessId -> StrictDynamic -> Process r (ResumeProcess ())
- ReceiveSelectedMessage :: forall r a. MessageSelector a -> Process r (ResumeProcess a)
- MakeReference :: Process r (ResumeProcess Int)
- Monitor :: ProcessId -> Process r (ResumeProcess MonitorReference)
- Demonitor :: MonitorReference -> Process r (ResumeProcess ())
- Link :: ProcessId -> Process r (ResumeProcess ())
- Unlink :: ProcessId -> Process r (ResumeProcess ())
- UpdateProcessDetails :: ProcessDetails -> Process r (ResumeProcess ())
- GetProcessState :: ProcessId -> Process r (ResumeProcess (Maybe (ProcessTitle, ProcessDetails, ProcessState)))
- fromProcessTitle :: Lens' ProcessTitle Text
- fromProcessDetails :: Lens' ProcessDetails Text
- toStrictDynamic :: (Typeable a, NFData a) => a -> StrictDynamic
- fromStrictDynamic :: Typeable a => StrictDynamic -> Maybe a
- unwrapStrictDynamic :: StrictDynamic -> Dynamic
- selectMessage :: Typeable t => MessageSelector t
- filterMessage :: Typeable a => (a -> Bool) -> MessageSelector a
- selectMessageWith :: Typeable a => (a -> Maybe b) -> MessageSelector b
- selectDynamicMessage :: (StrictDynamic -> Maybe a) -> MessageSelector a
- selectAnyMessage :: MessageSelector StrictDynamic
- toExitRecovery :: Interrupt r -> ExitRecovery
- toExitSeverity :: Interrupt e -> ExitSeverity
- interruptToExit :: Interrupt Recoverable -> Interrupt NoRecovery
- isProcessDownInterrupt :: Maybe ProcessId -> Interrupt r -> Bool
- provideInterruptsShutdown :: forall e a. Eff (Processes e) a -> Eff (SafeProcesses e) a
- handleInterrupts :: (HasCallStack, Member Interrupts r) => (Interrupt Recoverable -> Eff r a) -> Eff r a -> Eff r a
- tryUninterrupted :: (HasCallStack, Member Interrupts r) => Eff r a -> Eff r (Either (Interrupt Recoverable) a)
- logInterrupts :: forall r. (Member Logs r, HasCallStack, Member Interrupts r) => Eff r () -> Eff r ()
- exitOnInterrupt :: (HasCallStack, HasProcesses r q) => Eff r a -> Eff r a
- provideInterrupts :: HasCallStack => Eff (Interrupts ': r) a -> Eff r (Either (Interrupt Recoverable) a)
- mergeEitherInterruptAndExitReason :: Either (Interrupt Recoverable) (Interrupt NoRecovery) -> Interrupt NoRecovery
- interrupt :: (HasCallStack, Member Interrupts r) => Interrupt Recoverable -> Eff r a
- isCrash :: Interrupt x -> Bool
- isRecoverable :: Interrupt x -> Bool
- fromSomeExitReason :: SomeExitReason -> Either (Interrupt NoRecovery) (Interrupt Recoverable)
- toCrashReason :: Interrupt x -> Maybe Text
- logProcessExit :: forall e x. (Member Logs e, HasCallStack) => Interrupt x -> Eff e ()
- executeAndResume :: forall q r v. (HasSafeProcesses r q, HasCallStack) => Process q (ResumeProcess v) -> Eff r (Either (Interrupt Recoverable) v)
- executeAndResumeOrExit :: forall r q v. (HasSafeProcesses r q, HasCallStack) => Process q (ResumeProcess v) -> Eff r v
- executeAndResumeOrThrow :: forall q r v. (HasProcesses r q, HasCallStack) => Process q (ResumeProcess v) -> Eff r v
- yieldProcess :: forall r q. (HasProcesses r q, HasCallStack) => Eff r ()
- sendMessage :: forall r q o. (HasProcesses r q, HasCallStack, Typeable o, NFData o) => ProcessId -> o -> Eff r ()
- sendAnyMessage :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> StrictDynamic -> Eff r ()
- sendShutdown :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Interrupt NoRecovery -> Eff r ()
- sendInterrupt :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Interrupt Recoverable -> Eff r ()
- spawn :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId
- spawn_ :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (Processes q) () -> Eff r ()
- spawnLink :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId
- spawnRaw :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r ProcessId
- spawnRaw_ :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r ()
- isProcessAlive :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r Bool
- getProcessState :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r (Maybe (ProcessTitle, ProcessDetails, ProcessState))
- updateProcessDetails :: forall r q. (HasCallStack, HasProcesses r q) => ProcessDetails -> Eff r ()
- receiveAnyMessage :: forall r q. (HasCallStack, HasProcesses r q) => Eff r StrictDynamic
- receiveSelectedMessage :: forall r q a. (HasCallStack, Show a, HasProcesses r q) => MessageSelector a -> Eff r a
- receiveMessage :: forall a r q. (HasCallStack, Typeable a, NFData a, Show a, HasProcesses r q) => Eff r a
- flushMessages :: forall r q. (HasCallStack, HasProcesses r q) => Eff r [StrictDynamic]
- receiveSelectedLoop :: forall r q a endOfLoopResult. (HasSafeProcesses r q, HasCallStack) => MessageSelector a -> (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult
- receiveAnyLoop :: forall r q endOfLoopResult. (HasSafeProcesses r q, HasCallStack) => (Either (Interrupt Recoverable) StrictDynamic -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult
- receiveLoop :: forall r q a endOfLoopResult. (HasSafeProcesses r q, HasCallStack, NFData a, Typeable a) => (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult
- self :: (HasCallStack, HasSafeProcesses r q) => Eff r ProcessId
- makeReference :: (HasCallStack, HasProcesses r q) => Eff r Int
- monitor :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r MonitorReference
- demonitor :: forall r q. (HasCallStack, HasProcesses r q) => MonitorReference -> Eff r ()
- withMonitor :: (HasCallStack, HasProcesses r q) => ProcessId -> (MonitorReference -> Eff r a) -> Eff r a
- receiveWithMonitor :: (HasCallStack, HasProcesses r q, Typeable a, Show a) => ProcessId -> MessageSelector a -> Eff r (Either ProcessDown a)
- becauseProcessIsDown :: ProcessDown -> Interrupt Recoverable
- selectProcessDown :: MonitorReference -> MessageSelector ProcessDown
- selectProcessDownByProcessId :: ProcessId -> MessageSelector ProcessDown
- linkProcess :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r ()
- unlinkProcess :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r ()
- exitBecause :: forall r q a. (HasCallStack, HasSafeProcesses r q) => Interrupt NoRecovery -> Eff r a
- exitNormally :: forall r q a. (HasCallStack, HasSafeProcesses r q) => Eff r a
- exitWithError :: forall r q a. (HasCallStack, HasSafeProcesses r q) => String -> Eff r a
- data Receiver a = (NFData out, Typeable out, Show out) => Receiver {
- _receiverPid :: ProcessId
- _receiverSerializer :: a -> out
- fromProcessId :: Iso' ProcessId Int
- sendToReceiver :: (NFData o, HasProcesses r q) => Receiver o -> o -> Eff r ()
- receiverPid :: forall a. Lens' (Receiver a) ProcessId
- class (Typeable protocol, Typeable embeddedProtocol) => HasPduPrism protocol embeddedProtocol where
- embeddedPdu :: forall (result :: Synchronicity). Prism' (Pdu protocol result) (Pdu embeddedProtocol result)
- embedPdu :: forall (result :: Synchronicity). Pdu embeddedProtocol result -> Pdu protocol result
- fromPdu :: forall (result :: Synchronicity). Pdu protocol result -> Maybe (Pdu embeddedProtocol result)
- type family ProtocolReply (s :: Synchronicity) where ...
- data Synchronicity
- type TangiblePdu p r = (Typeable p, Typeable r, Tangible (Pdu p r), HasPdu p)
- type Tangible i = (NFData i, Typeable i, Show i)
- type Embeds outer inner = (HasPduPrism outer inner, CheckEmbeds outer inner, HasPdu outer)
- class Typeable protocol => HasPdu (protocol :: Type) where
- type EmbeddedPduList protocol :: [Type]
- data Pdu protocol (reply :: Synchronicity)
- newtype Endpoint protocol = Endpoint {}
- proxyAsEndpoint :: proxy protocol -> ProcessId -> Endpoint protocol
- asEndpoint :: forall protocol. ProcessId -> Endpoint protocol
- toEmbeddedEndpoint :: forall inner outer. Embeds outer inner => Endpoint outer -> Endpoint inner
- fromEmbeddedEndpoint :: forall outer inner. HasPduPrism outer inner => Endpoint inner -> Endpoint outer
- fromEndpoint :: forall protocol protocol. Iso (Endpoint protocol) (Endpoint protocol) ProcessId ProcessId
- newtype ReplyTarget p r = MkReplyTarget (Arg (RequestOrigin p r) (Serializer (Reply p r)))
- data RequestOrigin (proto :: Type) reply = RequestOrigin {}
- data Reply protocol reply where
- data Request protocol where
- Call :: forall protocol reply. (Tangible reply, TangiblePdu protocol (Synchronous reply)) => RequestOrigin protocol reply -> Pdu protocol (Synchronous reply) -> Request protocol
- Cast :: forall protocol. (TangiblePdu protocol Asynchronous, NFData (Pdu protocol Asynchronous)) => Pdu protocol Asynchronous -> Request protocol
- makeRequestOrigin :: (Typeable r, NFData r, HasProcesses e q0) => Eff e (RequestOrigin p r)
- toEmbeddedOrigin :: forall outer inner reply. Embeds outer inner => RequestOrigin outer reply -> RequestOrigin inner reply
- embedRequestOrigin :: forall outer inner reply. Embeds outer inner => RequestOrigin inner reply -> RequestOrigin outer reply
- embedReplySerializer :: forall outer inner reply. Embeds outer inner => Serializer (Reply outer reply) -> Serializer (Reply inner reply)
- sendReply :: (HasProcesses eff q, Tangible reply, Typeable protocol) => ReplyTarget protocol reply -> reply -> Eff eff ()
- replyTarget :: Serializer (Reply p reply) -> RequestOrigin p reply -> ReplyTarget p reply
- replyTargetOrigin :: Lens' (ReplyTarget p reply) (RequestOrigin p reply)
- replyTargetSerializer :: Lens' (ReplyTarget p reply) (Serializer (Reply p reply))
- embeddedReplyTarget :: Embeds outer inner => Serializer (Reply outer reply) -> RequestOrigin outer reply -> ReplyTarget inner reply
- toEmbeddedReplyTarget :: Embeds outer inner => ReplyTarget outer reply -> ReplyTarget inner reply
- data TimerElapsed
- data TimerReference
- data Timeout
- receiveAfter :: forall a r q. (Lifted IO q, HasCallStack, HasProcesses r q, Typeable a, NFData a, Show a) => Timeout -> Eff r (Maybe a)
- receiveSelectedAfter :: forall a r q. (Lifted IO q, HasCallStack, HasProcesses r q, Show a) => MessageSelector a -> Timeout -> Eff r (Either TimerElapsed a)
- receiveSelectedWithMonitorAfter :: forall a r q. (Lifted IO q, HasCallStack, HasProcesses r q, Show a) => ProcessId -> MessageSelector a -> Timeout -> Eff r (Either (Either ProcessDown TimerElapsed) a)
- selectTimerElapsed :: TimerReference -> MessageSelector TimerElapsed
- sendAfter :: forall r q message. (Lifted IO q, HasCallStack, HasProcesses r q, Typeable message, NFData message) => ProcessId -> Timeout -> (TimerReference -> message) -> Eff r TimerReference
- startTimer :: forall r q. (Lifted IO q, HasCallStack, HasProcesses r q) => Timeout -> Eff r TimerReference
- cancelTimer :: forall r q. (Lifted IO q, HasCallStack, HasProcesses r q) => TimerReference -> Eff r ()
- type EndpointReader o = Reader (Endpoint o)
- type HasEndpointReader o r = (Typeable o, Member (EndpointReader o) r)
- cast :: forall destination protocol r q. (HasCallStack, HasProcesses r q, HasPdu destination, HasPdu protocol, Tangible (Pdu destination Asynchronous), Embeds destination protocol) => Endpoint destination -> Pdu protocol Asynchronous -> Eff r ()
- call :: forall result destination protocol r q. (HasProcesses r q, TangiblePdu destination (Synchronous result), TangiblePdu protocol (Synchronous result), Tangible result, Embeds destination protocol, HasCallStack) => Endpoint destination -> Pdu protocol (Synchronous result) -> Eff r result
- callWithTimeout :: forall result destination protocol r q. (HasProcesses r q, TangiblePdu destination (Synchronous result), TangiblePdu protocol (Synchronous result), Tangible result, Member Logs r, Lifted IO q, Lifted IO r, HasCallStack, Embeds destination protocol) => Endpoint destination -> Pdu protocol (Synchronous result) -> Timeout -> Eff r result
- runEndpointReader :: HasCallStack => Endpoint o -> Eff (EndpointReader o ': r) a -> Eff r a
- askEndpoint :: Member (EndpointReader o) e => Eff e (Endpoint o)
- callEndpointReader :: forall reply o r q. (HasEndpointReader o r, HasCallStack, Tangible reply, TangiblePdu o (Synchronous reply), HasProcesses r q, Embeds o o) => Pdu o (Synchronous reply) -> Eff r reply
- castEndpointReader :: forall o r q. (HasEndpointReader o r, HasProcesses r q, Tangible (Pdu o Asynchronous), HasCallStack, HasPdu o, Embeds o o) => Pdu o Asynchronous -> Eff r ()
- callSingleton :: forall outer inner reply q e. (HasCallStack, Member (EndpointReader outer) e, Embeds outer inner, Embeds outer outer, HasProcesses e q, TangiblePdu outer (Synchronous reply), TangiblePdu inner (Synchronous reply), Tangible reply) => Pdu inner (Synchronous reply) -> Eff e reply
- castSingleton :: forall outer inner q e. (HasCallStack, Member (EndpointReader outer) e, Tangible (Pdu outer Asynchronous), HasProcesses e q, HasPdu outer, HasPdu inner, Embeds outer inner, Embeds outer outer) => Pdu inner Asynchronous -> Eff e ()
- type ObserverRegistryState event = State (ObserverRegistry event)
- data ObserverRegistry (event :: Type) = MkObserverRegistry {
- _observerRegistry :: Map ProcessId (ObservationSink event)
- type CanObserve eventSink event = (Tangible event, Embeds eventSink (Observer event), HasPdu eventSink)
- type IsObservable eventSource event = (Tangible event, Embeds eventSource (ObserverRegistry event), HasPdu eventSource)
- data ObservationSink event
- newtype Observer event = MkObserver (Arg ProcessId (ObservationSink event))
- registerObserver :: forall event eventSink eventSource r q. (HasCallStack, HasProcesses r q, IsObservable eventSource event, Tangible (Pdu eventSource Asynchronous), Tangible (Pdu eventSink Asynchronous), CanObserve eventSink event) => Endpoint eventSource -> Endpoint eventSink -> Eff r ()
- forgetObserver :: forall event eventSink eventSource r q. (HasProcesses r q, HasCallStack, Tangible (Pdu eventSource Asynchronous), Tangible (Pdu eventSink Asynchronous), IsObservable eventSource event, CanObserve eventSink event) => Endpoint eventSource -> Endpoint eventSink -> Eff r ()
- forgetObserverUnsafe :: forall event eventSource r q. (HasProcesses r q, HasCallStack, Tangible (Pdu eventSource Asynchronous), IsObservable eventSource event) => Endpoint eventSource -> ProcessId -> Eff r ()
- observerRegistryHandlePdu :: forall event q r. (HasCallStack, Typeable event, HasProcesses r q, Member (ObserverRegistryState event) r, Member Logs r) => Pdu (ObserverRegistry event) Asynchronous -> Eff r ()
- observerRegistryRemoveProcess :: forall event q r. (HasCallStack, Typeable event, HasProcesses r q, Member (ObserverRegistryState event) r, Member Logs r) => ProcessId -> Eff r Bool
- evalObserverRegistryState :: HasCallStack => Eff (ObserverRegistryState event ': r) a -> Eff r a
- emptyObserverRegistry :: ObserverRegistry event
- observerRegistryNotify :: forall event r q. (HasProcesses r q, Member (ObserverRegistryState event) r, Tangible event, HasCallStack) => event -> Eff r ()
- type CaptureLogWriter = Writer LogMessage
- type CaptureLogs a = LogWriterM CaptureLogWriter a
- captureLogWriter :: LogWriter CaptureLogWriter
- runCaptureLogWriter :: Eff (CaptureLogWriter ': e) a -> Eff e (a, [LogMessage])
- type LoggingAndIo = '[Logs, LogWriterReader (Lift IO), Lift IO]
- mkLogWriterIO :: HasCallStack => (LogMessage -> IO ()) -> LogWriter (Lift IO)
- ioHandleLogWriter :: HasCallStack => Handle -> LogWriter (Lift IO)
- withIoLogging :: Lifted IO e => LogWriter (Lift IO) -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- defaultIoLogWriter :: Text -> Facility -> LogWriter (Lift IO) -> LogWriter (Lift IO)
- printLogMessage :: LogMessage -> IO ()
- withFileLogging :: (Lifted IO e, MonadBaseControl IO (Eff e)) => FilePath -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- withFileLogWriter :: (LogIo e, MonadBaseControl IO (Eff e)) => FilePath -> Eff e b -> Eff e b
- withTraceLogging :: Lifted IO e => Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- withTraceLogWriter :: forall h e a. (Monad (LogWriterM h), LogsTo h e) => Eff e a -> Eff e a
- debugTraceLogWriter :: forall h. Monad (LogWriterM h) => LogMessageRenderer Text -> LogWriter h
- withConsoleLogging :: Lifted IO e => Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- withConsoleLogWriter :: LogIo e => Eff e a -> Eff e a
- consoleLogWriter :: LogWriter (Lift IO)
- stdoutLogWriter :: LogMessageRenderer Text -> LogWriter (Lift IO)
- withAsyncLogging :: (Lifted IO e, MonadBaseControl IO (Eff e), Integral len) => LogWriter (Lift IO) -> len -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- withAsyncLogWriter :: (LogIo e, MonadBaseControl IO (Eff e), Integral len) => len -> Eff e a -> Eff e a
- withUDPLogging :: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) => (LogMessage -> Text) -> String -> String -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- withUDPLogWriter :: (LogIo e, MonadBaseControl IO (Eff e), HasCallStack) => (LogMessage -> Text) -> String -> String -> Eff e b -> Eff e b
- withUnixSocketLogging :: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) => LogMessageRenderer Text -> FilePath -> Text -> Facility -> LogPredicate -> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a -> Eff e a
- withUnixSocketLogWriter :: (LogIo e, MonadBaseControl IO (Eff e), HasCallStack) => LogMessageRenderer Text -> FilePath -> Eff e b -> Eff e b
- foreverCheap :: Monad m => m a -> m ()
- replicateCheapM_ :: Monad m => Int -> m a -> m ()
- schedule :: HasCallStack => LogWriter (Lift IO) -> Eff Effects a -> IO (Either (Interrupt NoRecovery) a)
- defaultMain :: HasCallStack => Eff EffectsIo () -> IO ()
- defaultMainWithLogWriter :: HasCallStack => LogWriter (Lift IO) -> Eff EffectsIo () -> IO ()
- type Effects = EffectsIo
- type SafeEffects = SafeEffectsIo
- type BaseEffects = BaseEffectsIo
- type HasBaseEffects e = HasBaseEffectsIo e
Generic functions and type for Processes and Messages
An rfc 5424 facility
Instances
Eq Facility Source # | |
Ord Facility Source # | |
Defined in Control.Eff.Log.Message | |
Show Facility Source # | |
Generic Facility Source # | |
Default Facility Source # | |
Defined in Control.Eff.Log.Message | |
NFData Facility Source # | |
Defined in Control.Eff.Log.Message | |
type Rep Facility Source # | |
Defined in Control.Eff.Log.Message |
An rfc 5424 severity
Instances
Eq Severity Source # | |
Ord Severity Source # | |
Defined in Control.Eff.Log.Message | |
Show Severity Source # | |
Generic Severity Source # | |
Default Severity Source # | |
Defined in Control.Eff.Log.Message | |
NFData Severity Source # | |
Defined in Control.Eff.Log.Message | |
type Rep Severity Source # | |
Defined in Control.Eff.Log.Message |
data SdParameter Source #
Component of an RFC-5424 StructuredDataElement
Instances
data StructuredDataElement Source #
RFC-5424 defines how structured data can be included in a log message.
SdElement | |
|
Instances
data LogMessage Source #
A message data type inspired by the RFC-5424 Syslog Protocol
MkLogMessage | |
|
Instances
emergencySeverity :: Severity Source #
Smart constructor for the RFC-5424 emergency LogMessage
Severity
.
This corresponds to the severity value 0.
See lmSeverity
.
alertSeverity :: Severity Source #
Smart constructor for the RFC-5424 alert LogMessage
Severity
.
This corresponds to the severity value 1.
See lmSeverity
.
criticalSeverity :: Severity Source #
Smart constructor for the RFC-5424 critical LogMessage
Severity
.
This corresponds to the severity value 2.
See lmSeverity
.
errorSeverity :: Severity Source #
Smart constructor for the RFC-5424 error LogMessage
Severity
.
This corresponds to the severity value 3.
See lmSeverity
.
warningSeverity :: Severity Source #
Smart constructor for the RFC-5424 warning LogMessage
Severity
.
This corresponds to the severity value 4.
See lmSeverity
.
noticeSeverity :: Severity Source #
Smart constructor for the RFC-5424 notice LogMessage
Severity
.
This corresponds to the severity value 5.
See lmSeverity
.
informationalSeverity :: Severity Source #
Smart constructor for the RFC-5424 informational LogMessage
Severity
.
This corresponds to the severity value 6.
See lmSeverity
.
debugSeverity :: Severity Source #
Smart constructor for the RFC-5424 debug LogMessage
Severity
.
This corresponds to the severity value 7.
See lmSeverity
.
kernelMessages :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility kernelMessages
.
See lmFacility
.
userLevelMessages :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility userLevelMessages
.
See lmFacility
.
mailSystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility mailSystem
.
See lmFacility
.
systemDaemons :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility systemDaemons
.
See lmFacility
.
securityAuthorizationMessages4 :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility securityAuthorizationMessages4
.
See lmFacility
.
linePrinterSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility linePrinterSubsystem
.
See lmFacility
.
networkNewsSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility networkNewsSubsystem
.
See lmFacility
.
uucpSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility uucpSubsystem
.
See lmFacility
.
clockDaemon :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility clockDaemon
.
See lmFacility
.
securityAuthorizationMessages10 :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility securityAuthorizationMessages10
.
See lmFacility
.
ftpDaemon :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility ftpDaemon
.
See lmFacility
.
ntpSubsystem :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility ntpSubsystem
.
See lmFacility
.
logAuditFacility :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility logAuditFacility
.
See lmFacility
.
logAlertFacility :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility logAlertFacility
.
See lmFacility
.
clockDaemon2 :: Facility Source #
Smart constructor for the RFC-5424 LogMessage
facility clockDaemon2
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local0
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local1
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local2
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local3
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local4
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local5
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local6
.
See lmFacility
.
Smart constructor for the RFC-5424 LogMessage
facility local7
.
See lmFacility
.
sdElementId :: Functor f => (Text -> f Text) -> StructuredDataElement -> f StructuredDataElement Source #
A lens for the key or ID of a group of RFC 5424 key-value pairs.
sdElementParameters :: Functor f => ([SdParameter] -> f [SdParameter]) -> StructuredDataElement -> f StructuredDataElement Source #
A lens for SdParameter
s
type LogPredicate = LogMessage -> Bool Source #
The filter predicate for message that shall be logged.
See Control.Eff.Log
class ToLogMessage a where Source #
Things that can become a LogMessage
toLogMessage :: a -> LogMessage Source #
Convert the value to a LogMessage
Instances
ToLogMessage Text Source # | |
Defined in Control.Eff.Log.Message toLogMessage :: Text -> LogMessage Source # | |
ToLogMessage LogMessage Source # | |
Defined in Control.Eff.Log.Message toLogMessage :: LogMessage -> LogMessage Source # |
lmAppName :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for the RFC 5424 application name of a LogMessage
One useful pattern for using this field, is to implement log filters that allow info and debug message from the application itself while only allowing warning and error messages from third party libraries:
debugLogsForAppName myAppName lm = view lmAppName lm == Just myAppName || lmSeverityIsAtLeast warningSeverity lm
This concept is also implemented in discriminateByAppName
.
lmFacility :: Functor f => (Facility -> f Facility) -> LogMessage -> f LogMessage Source #
A lens for the Facility
of a LogMessage
lmHostname :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for the hostname of a LogMessage
The function setLogMessageHostname
can be used to set the field.
lmMessage :: Functor f => (Text -> f Text) -> LogMessage -> f LogMessage Source #
A lens for the user defined textual message of a LogMessage
lmMessageId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for a user defined message id of a LogMessage
lmProcessId :: Functor f => (Maybe Text -> f (Maybe Text)) -> LogMessage -> f LogMessage Source #
A lens for a user defined of process id of a LogMessage
lmSeverity :: Functor f => (Severity -> f Severity) -> LogMessage -> f LogMessage Source #
A lens for the Severity
of a LogMessage
lmSrcLoc :: Functor f => (Maybe SrcLoc -> f (Maybe SrcLoc)) -> LogMessage -> f LogMessage Source #
A lens for the SrcLoc
of a LogMessage
lmStructuredData :: Functor f => ([StructuredDataElement] -> f [StructuredDataElement]) -> LogMessage -> f LogMessage Source #
A lens for the StructuredDataElement
of a LogMessage
lmThreadId :: Functor f => (Maybe ThreadId -> f (Maybe ThreadId)) -> LogMessage -> f LogMessage Source #
A lens for the ThreadId
of a LogMessage
The function setLogMessageThreadId
can be used to set the field.
lmTimestamp :: Functor f => (Maybe UTCTime -> f (Maybe UTCTime)) -> LogMessage -> f LogMessage Source #
A lens for the UTC time of a LogMessage
The function setLogMessageTimestamp
can be used to set the field.
setCallStack :: CallStack -> LogMessage -> LogMessage Source #
Put the source location of the given callstack in lmSrcLoc
prefixLogMessagesWith :: Text -> LogMessage -> LogMessage Source #
Prefix the lmMessage
.
setLogMessageTimestamp :: LogMessage -> IO LogMessage Source #
An IO action that sets the current UTC time in lmTimestamp
.
setLogMessageThreadId :: LogMessage -> IO LogMessage Source #
An IO action appends the the ThreadId
of the calling process (see myThreadId
)
to lmMessage
.
setLogMessageHostname :: LogMessage -> IO LogMessage Source #
An IO action that sets the current hosts fully qualified hostname in lmHostname
.
errorMessage :: HasCallStack => Text -> LogMessage Source #
Construct a LogMessage
with errorSeverity
infoMessage :: HasCallStack => Text -> LogMessage Source #
Construct a LogMessage
with informationalSeverity
debugMessage :: HasCallStack => Text -> LogMessage Source #
Construct a LogMessage
with debugSeverity
errorMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage Source #
Construct a LogMessage
with errorSeverity
infoMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage Source #
Construct a LogMessage
with informationalSeverity
debugMessageIO :: (HasCallStack, MonadIO m) => Text -> m LogMessage Source #
Construct a LogMessage
with debugSeverity
allLogMessages :: LogPredicate Source #
All messages.
See Control.Eff.Log.Message for more predicates.
noLogMessages :: LogPredicate Source #
No messages.
See Control.Eff.Log.Message for more predicates.
lmSeverityIs :: Severity -> LogPredicate Source #
Match LogMessage
s that have exactly the given severity.
See lmSeverityIsAtLeast
.
See Control.Eff.Log.Message for more predicates.
lmSeverityIsAtLeast :: Severity -> LogPredicate Source #
Match LogMessage
s that have the given severity or worse.
See lmSeverityIs
.
See Control.Eff.Log.Message for more predicates.
lmMessageStartsWith :: Text -> LogPredicate Source #
Match LogMessage
s whose lmMessage
starts with the given string.
See Control.Eff.Log.Message for more predicates.
discriminateByAppName :: Text -> LogPredicate -> LogPredicate -> LogPredicate Source #
Apply a LogPredicate
based on the lmAppName
and delegate
to one of two LogPredicate
s.
One useful application for this is to allow info and debug message from one application, e.g. the current application itself, while at the same time allowing only warning and error messages from third party libraries.
See Control.Eff.Log.Message for more predicates.
data LogMessageTimeRenderer Source #
A rendering function for the lmTimestamp
field.
type LogMessageRenderer a = LogMessage -> a Source #
LogMessage
rendering function
mkLogMessageTimeRenderer Source #
:: String | The format string that is passed to |
-> LogMessageTimeRenderer |
Make a LogMessageTimeRenderer
using formatTime
in the defaultLocale
.
suppressTimestamp :: LogMessageTimeRenderer Source #
Don't render the time stamp
rfc3164Timestamp :: LogMessageTimeRenderer Source #
Render the time stamp using "%h %d %H:%M:%S"
rfc5424Timestamp :: LogMessageTimeRenderer Source #
Render the time stamp to iso8601DateFormat
(Just "%H:%M:%S%6QZ")
rfc5424NoZTimestamp :: LogMessageTimeRenderer Source #
Render the time stamp like rfc5424Timestamp
does, but omit the terminal Z
character.
renderLogMessageBody :: LogMessageRenderer Text Source #
Print the thread id, the message and the source file location, seperated by simple white space.
renderLogMessageBodyNoLocation :: LogMessageRenderer Text Source #
Print the thread id, the message and the source file location, seperated by simple white space.
renderLogMessageBodyFixWidth :: LogMessageRenderer Text Source #
Print the body of a LogMessage
with fix size fields (60) for the message itself
and 30 characters for the location
renderMaybeLogMessageLens :: Text -> Getter LogMessage (Maybe Text) -> LogMessageRenderer Text Source #
Render a field of a LogMessage
using the corresponsing lens.
renderLogMessageSrcLoc :: LogMessageRenderer (Maybe Text) Source #
Render the source location as: at filepath:linenumber
.
renderSyslogSeverityAndFacility :: LogMessageRenderer Text Source #
Render the severity and facility as described in RFC-3164
Render e.g. as <192>
.
Useful as header for syslog compatible log output.
renderLogMessageSyslog :: LogMessageRenderer Text Source #
Render the LogMessage
to contain the severity, message, message-id, pid.
Omit hostname, PID and timestamp.
Render the header using renderSyslogSeverity
Useful for logging to devlog
renderLogMessageConsoleLog :: LogMessageRenderer Text Source #
Render a LogMessage
human readable, for console logging
renderRFC3164 :: LogMessageRenderer Text Source #
Render a LogMessage
according to the rules in the RFC-3164.
renderRFC3164WithRFC5424Timestamps :: LogMessageRenderer Text Source #
Render a LogMessage
according to the rules in the RFC-3164 but use
RFC5424 time stamps.
renderRFC3164WithTimestamp :: LogMessageTimeRenderer -> LogMessageRenderer Text Source #
Render a LogMessage
according to the rules in the RFC-3164 but use the custom
LogMessageTimeRenderer
.
renderRFC5424 :: LogMessageRenderer Text Source #
Render a LogMessage
according to the rules in the RFC-5424.
Equivalent to
.renderRFC5424Header
<> const " " <> renderLogMessageBody
Since: 0.21.0
renderRFC5424NoLocation :: LogMessageRenderer Text Source #
Render a LogMessage
according to the rules in the RFC-5424, like renderRFC5424
but
suppress the source location information.
Equivalent to
.renderRFC5424Header
<> const " " <> renderLogMessageBodyNoLocation
Since: 0.21.0
renderRFC5424Header :: LogMessageRenderer Text Source #
Render the header and strucuted data of a LogMessage
according to the rules in the RFC-5424, but do not
render the lmMessage
.
Since: 0.22.0
class HandleLogWriter (writer :: Type -> Type) where Source #
The instances of this class are the monads that define (side-) effect(s) of writting logs.
data LogWriterM writer a Source #
The Eff
ects required by the handleLogWriterEffect
method.
Since: 0.29.1
handleLogWriterEffect :: Member writer e => LogWriterM writer () -> Eff e () Source #
liftWriteLogMessage :: (SetMember LogWriterReader (LogWriterReader writer) e, Member writer e) => LogMessage -> Eff e () Source #
Write a message using the LogWriter
found in the environment.
The semantics of this function are a combination of runLogWriter
and handleLogWriterEffect
,
with the LogWriter
read from a LogWriterReader
.
Instances
data LogWriterReader h v Source #
A Reader specialized for LogWriter
s
The existing Reader
couldn't be used together with SetMember
, so this
lazy reader was written, specialized to reading LogWriter
.
Instances
newtype LogWriter writerM Source #
A function that takes a log message and returns an effect that logs the message.
MkLogWriter | |
|
Instances
Applicative (LogWriterM w) => Default (LogWriter w) Source # | |
Defined in Control.Eff.Log.Writer | |
Handle (LogWriterReader h) e a (LogWriter h -> k) Source # | |
Defined in Control.Eff.Log.Writer handle :: (Eff e a -> LogWriter h -> k) -> Arrs e v a -> LogWriterReader h v -> LogWriter h -> k # handle_relay :: (e ~ (LogWriterReader h ': r'), Relay (LogWriter h -> k) r') => (a -> LogWriter h -> k) -> (Eff e a -> LogWriter h -> k) -> Eff e a -> LogWriter h -> k # respond_relay :: (a -> LogWriter h -> k) -> (Eff e a -> LogWriter h -> k) -> Eff e a -> LogWriter h -> k # |
runLogWriterReader :: LogWriter h -> Eff (LogWriterReader h ': e) a -> Eff e a Source #
Provide the LogWriter
Exposed for custom extensions, if in doubt use withLogging
.
askLogWriter :: SetMember LogWriterReader (LogWriterReader h) e => Eff e (LogWriter h) Source #
Get the current LogWriter
.
localLogWriterReader :: forall h e a. SetMember LogWriterReader (LogWriterReader h) e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a Source #
Modify the current LogWriter
.
noOpLogWriter :: Applicative (LogWriterM m) => LogWriter m Source #
filteringLogWriter :: Monad (LogWriterM e) => LogPredicate -> LogWriter e -> LogWriter e Source #
A LogWriter
that applies a predicate to the LogMessage
and delegates to
to the given writer of the predicate is satisfied.
mappingLogWriter :: (LogMessage -> LogMessage) -> LogWriter e -> LogWriter e Source #
A LogWriter
that applies a function to the LogMessage
and delegates the result to
to the given writer.
mappingLogWriterM :: Monad (LogWriterM e) => (LogMessage -> LogWriterM e LogMessage) -> LogWriter e -> LogWriter e Source #
Like mappingLogWriter
allow the function that changes the LogMessage
to have effects.
type LogsTo h e = (Member Logs e, HandleLogWriter h, Member h e, SetMember LogWriterReader (LogWriterReader h) e) Source #
A constraint alias for effects that requires a LogWriterReader
, as well as that the
contained LogWriterReader
has a HandleLogWriter
instance.
The requirements of this constraint are provided by:
withIoLogging
withLogging
withSomeLogging
This effect sends LogMessage
s and is a reader for a LogPredicate
.
Logs are sent via logMsg
;
for more information about log predicates, see Control.Eff.Log
This effect is handled via withLogging
.
Instances
withLogging :: forall h e a. (Applicative (LogWriterM h), LogsTo h (Logs ': (LogWriterReader h ': e))) => LogWriter h -> Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a Source #
Handle the Logs
and LogWriterReader
effects.
It installs the given LogWriter
, which determines the underlying
LogWriter
type parameter.
Example:
exampleWithLogging :: IO () exampleWithLogging = runLift $ withLogging consoleLogWriter $ logDebug "Oh, hi there"
withSomeLogging :: forall h e a. (Applicative (LogWriterM h), LogsTo h (Logs ': (LogWriterReader h ': e))) => Eff (Logs ': (LogWriterReader h ': e)) a -> Eff e a Source #
Handles the Logs
and LogWriterReader
effects.
By default it uses the noOpLogWriter
, but using setLogWriter
the
LogWriter
can be replaced.
This is like withLogging
applied to noOpLogWriter
Example:
exampleWithSomeLogging :: () exampleWithSomeLogging = run $ withSomeLogging @PureLogWriter $ logDebug "Oh, hi there"
runLogs :: forall h e b. LogsTo h (Logs ': e) => LogPredicate -> Eff (Logs ': e) b -> Eff e b Source #
Raw handling of the Logs
effect.
Exposed for custom extensions, if in doubt use withLogging
.
logMsg :: forall e. (HasCallStack, Member Logs e) => LogMessage -> Eff e () Source #
Log a message.
All logging goes through this function.
This function is the only place where the LogPredicate
is applied.
Also, LogMessage
s are evaluated using deepseq
, after they pass the LogPredicate
.
logWithSeverity :: forall e. (HasCallStack, Member Logs e) => Severity -> Text -> Eff e () Source #
Log a Text
as LogMessage
with a given Severity
.
logWithSeverity' :: forall e. (HasCallStack, Member Logs e) => Severity -> String -> Eff e () Source #
Log a Text
as LogMessage
with a given Severity
.
logEmergency :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a String
as emergencySeverity
.
logAlert :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a message with alertSeverity
.
logCritical :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a criticalSeverity
message.
logError :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a errorSeverity
message.
logWarning :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a warningSeverity
message.
logNotice :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a noticeSeverity
message.
logInfo :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a informationalSeverity
message.
logDebug :: forall e. (HasCallStack, Member Logs e) => Text -> Eff e () Source #
Log a debugSeverity
message.
logEmergency' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a String
as emergencySeverity
.
logAlert' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a message with alertSeverity
.
logCritical' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a criticalSeverity
message.
logError' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a errorSeverity
message.
logWarning' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a warningSeverity
message.
logNotice' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a noticeSeverity
message.
logInfo' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a informationalSeverity
message.
logDebug' :: forall e. (HasCallStack, Member Logs e) => String -> Eff e () Source #
Log a debugSeverity
message.
askLogPredicate :: forall e. Member Logs e => Eff e LogPredicate Source #
Get the current Logs
filter/transformer function.
See Control.Eff.Log
setLogPredicate :: forall r b. (Member Logs r, HasCallStack) => LogPredicate -> Eff r b -> Eff r b Source #
Keep only those messages, for which a predicate holds.
E.g. to keep only messages which begin with OMG
:
exampleLogPredicate :: IO Int exampleLogPredicate = runLift $ withLogging consoleLogWriter $ do logMsg "test" setLogPredicate (\ msg -> case view lmMessage msg of 'O':'M':'G':_ -> True _ -> False) (do logMsg "this message will not be logged" logMsg "OMG logged" return 42)
In order to also delegate to the previous predicate, use modifyLogPredicate
See Control.Eff.Log
modifyLogPredicate :: forall e b. (Member Logs e, HasCallStack) => (LogPredicate -> LogPredicate) -> Eff e b -> Eff e b Source #
Change the LogPredicate
.
Other than setLogPredicate
this function allows to include the previous predicate, too.
For to discard all messages currently no satisfying the predicate and also all messages that are to long:
modifyLogPredicate (previousPredicate msg -> previousPredicate msg && length (lmMessage msg) < 29 ) (do logMsg "this message will not be logged" logMsg "this message might be logged")
See Control.Eff.Log
includeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a Source #
Include LogMessage
s that match a LogPredicate
.
excludeLogMessages p
allows log message to be logged if p m
Although it is enough if the previous predicate holds.
See excludeLogMessages
and modifyLogPredicate
.
See Control.Eff.Log
excludeLogMessages :: forall e a. Member Logs e => LogPredicate -> Eff e a -> Eff e a Source #
Exclude LogMessage
s that match a LogPredicate
.
excludeLogMessages p
discards logs if p m
Also the previous predicate must also hold for a
message to be logged.
See excludeLogMessages
and modifyLogPredicate
.
See Control.Eff.Log
respondToLogMessage :: forall r b. Member Logs r => (LogMessage -> Eff r ()) -> Eff r b -> Eff r b Source #
Consume log messages.
Exposed for custom extensions, if in doubt use withLogging
.
Respond to all LogMessage
s logged from the given action,
up to any MonadBaseControl
liftings.
Note that all logging is done through logMsg
and that means
only messages passing the LogPredicate
are received.
The LogMessage
s are consumed once they are passed to the
given callback function, previous respondToLogMessage
invocations
further up in the call stack will not get the messages anymore.
Use interceptLogMessages
if the messages shall be passed
any previous handler.
NOTE: The effects of this function are lost when using
MonadBaseControl
, MonadMask
, MonadCatch
and MonadThrow
.
In contrast the functions based on modifying the LogWriter
,
such as addLogWriter
or censorLogs
, are save to use in combination
with the aforementioned liftings.
interceptLogMessages :: forall r b. Member Logs r => (LogMessage -> Eff r LogMessage) -> Eff r b -> Eff r b Source #
Change the LogMessage
s using an effectful function.
Exposed for custom extensions, if in doubt use withLogging
.
This differs from respondToLogMessage
in that the intercepted messages will be
written either way, albeit in altered form.
NOTE: The effects of this function are lost when using
MonadBaseControl
, MonadMask
, MonadCatch
and MonadThrow
.
In contrast the functions based on modifying the LogWriter
,
such as addLogWriter
or censorLogs
, are save to use in combination
with the aforementioned liftings.
modifyLogWriter :: forall h e a. LogsTo h e => (LogWriter h -> LogWriter h) -> Eff e a -> Eff e a Source #
Change the current LogWriter
.
setLogWriter :: forall h e a. LogsTo h e => LogWriter h -> Eff e a -> Eff e a Source #
Replace the current LogWriter
.
To add an additional log message consumer use addLogWriter
censorLogs :: LogsTo h e => (LogMessage -> LogMessage) -> Eff e a -> Eff e a Source #
Modify the the LogMessage
s written in the given sub-expression.
Note: This is equivalent to modifyLogWriter
. mappingLogWriter
censorLogsM :: (LogsTo h e, Monad (LogWriterM h)) => (LogMessage -> LogWriterM h LogMessage) -> Eff e a -> Eff e a Source #
Modify the the LogMessage
s written in the given sub-expression, as in censorLogs
but with a effectful function.
Note: This is equivalent to modifyLogWriter
. mappingLogWriterM
addLogWriter :: forall h e a. (HasCallStack, LogsTo h e, Monad (LogWriterM h)) => LogWriter h -> Eff e a -> Eff e a Source #
Combine the effects of a given LogWriter
and the existing one.
import Data.Text as T import Data.Text.IO as T exampleAddLogWriter :: IO () exampleAddLogWriter = go >>= T.putStrLn where go = fmap (unlines . map renderLogMessageConsoleLog . snd) $ runLift $ runCaptureLogWriter $ withLogging captureLogWriter $ addLogWriter (mappingLogWriter (lmMessage %~ ("CAPTURED "++)) captureLogWriter) $ addLogWriter (filteringLogWriter severeMessages (mappingLogWriter (lmMessage %~ ("TRACED "++)) debugTraceLogWriter)) $ do logEmergency "test emergencySeverity 1" logCritical "test criticalSeverity 2" logAlert "test alertSeverity 3" logError "test errorSeverity 4" logWarning "test warningSeverity 5" logInfo "test informationalSeverity 6" logDebug "test debugSeverity 7" severeMessages = view (lmSeverity . to (<= errorSeverity))
Each process is identified by a single process id, that stays constant throughout the life cycle of a process. Also, message sending relies on these values to address messages to processes.
Instances
Bounded ProcessId Source # | |
Enum ProcessId Source # | |
Defined in Control.Eff.Concurrent.Process succ :: ProcessId -> ProcessId # pred :: ProcessId -> ProcessId # fromEnum :: ProcessId -> Int # enumFrom :: ProcessId -> [ProcessId] # enumFromThen :: ProcessId -> ProcessId -> [ProcessId] # enumFromTo :: ProcessId -> ProcessId -> [ProcessId] # enumFromThenTo :: ProcessId -> ProcessId -> ProcessId -> [ProcessId] # | |
Eq ProcessId Source # | |
Integral ProcessId Source # | |
Defined in Control.Eff.Concurrent.Process | |
Num ProcessId Source # | |
Defined in Control.Eff.Concurrent.Process | |
Ord ProcessId Source # | |
Defined in Control.Eff.Concurrent.Process | |
Read ProcessId Source # | |
Real ProcessId Source # | |
Defined in Control.Eff.Concurrent.Process toRational :: ProcessId -> Rational # | |
Show ProcessId Source # | |
NFData ProcessId Source # | |
Defined in Control.Eff.Concurrent.Process |
data ProcessDown Source #
A monitored process exited. This message is sent to a process by the scheduler, when a process that was monitored died.
Since: 0.12.0
Instances
data MonitorReference Source #
A value that contains a unique reference of a process monitoring.
Since: 0.12.0
Instances
data SomeExitReason where Source #
An existential wrapper around Interrupt
SomeExitReason :: Interrupt x -> SomeExitReason |
Instances
Eq SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process (==) :: SomeExitReason -> SomeExitReason -> Bool # (/=) :: SomeExitReason -> SomeExitReason -> Bool # | |
Ord SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process compare :: SomeExitReason -> SomeExitReason -> Ordering # (<) :: SomeExitReason -> SomeExitReason -> Bool # (<=) :: SomeExitReason -> SomeExitReason -> Bool # (>) :: SomeExitReason -> SomeExitReason -> Bool # (>=) :: SomeExitReason -> SomeExitReason -> Bool # max :: SomeExitReason -> SomeExitReason -> SomeExitReason # min :: SomeExitReason -> SomeExitReason -> SomeExitReason # | |
Show SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process showsPrec :: Int -> SomeExitReason -> ShowS # show :: SomeExitReason -> String # showList :: [SomeExitReason] -> ShowS # | |
NFData SomeExitReason Source # | |
Defined in Control.Eff.Concurrent.Process rnf :: SomeExitReason -> () # |
type Interrupts = Exc (Interrupt Recoverable) Source #
Exc
eptions containing Interrupt
s.
See handleInterrupts
, exitOnInterrupt
or provideInterrupts
type HasSafeProcesses e inner = SetMember Process (Process inner) e Source #
A constraint for an effect set that requires the presence of SafeProcesses
.
This constrains the effect list to look like this:
[e1 ... eN,
Process
[e(N+1) .. e(N+k)], e(N+1) .. e(N+k)]
It contrains e
to support the (only) Process
effect.
This is more relaxed that HasProcesses
since it does not require Interrupts
.
Since: 0.27.1
type SafeProcesses r = Process r ': r Source #
Cons Process
onto a list of effects. This is called SafeProcesses
because
the the actions cannot be interrupted in.
type HasProcesses e inner = (HasSafeProcesses e inner, Member Interrupts e) Source #
A constraint for an effect set that requires the presence of Processes
.
This constrains the effect list to look like this:
[e1 ... eN,
Interrupts
, Process
[e(N+1) .. e(N+k)], e(N+1) .. e(N+k)]
It contrains e
beyond HasSafeProcesses
to encompass Interrupts
.
Since: 0.27.1
type Processes e = Interrupts ': SafeProcesses e Source #
This adds a layer of the Interrupts
effect on top of Processes
type RecoverableInterrupt = Interrupt Recoverable Source #
Interrupt
s which are Recoverable
.
data Interrupt (t :: ExitRecovery) where Source #
A sum-type with reasons for why a process operation, such as receiving messages, is interrupted in the scheduling loop.
This includes errors, that can occur when scheduling messages.
Since: 0.23.0
NormalExitRequested :: Interrupt Recoverable | A process has finished a unit of work and might exit or work on
something else. This is primarily used for interrupting infinite
server loops, allowing for additional cleanup work before
exiting (e.g. with Since: 0.13.2 |
OtherProcessNotRunning :: ProcessId -> Interrupt Recoverable | A process that should be running was not running. |
TimeoutInterrupt :: String -> Interrupt Recoverable | A |
LinkedProcessCrashed :: ProcessId -> Interrupt Recoverable | A linked process is down |
ErrorInterrupt :: String -> Interrupt Recoverable | An exit reason that has an error message and is |
ExitNormally :: Interrupt NoRecovery | A process function returned or exited without any error. |
ExitUnhandledError :: Text -> Interrupt NoRecovery | An error causes the process to exit immediately.
For example an unexpected runtime exception was thrown, i.e. an exception
derived from |
ExitProcessCancelled :: Interrupt NoRecovery | A process shall exit immediately, without any cleanup was cancelled (e.g. killed, in |
Instances
data ExitSeverity Source #
This value indicates whether a process exited in way consistent with the planned behaviour or not.
Instances
data ExitRecovery Source #
This kind is used to indicate if a Interrupt
can be treated like
a short interrupt which can be handled or ignored.
Instances
data MessageSelector a Source #
A function that decided if the next message will be received by
ReceiveSelectedMessage
. It conveniently is an instance of
Alternative
so the message selector can be combined:
>
> selectInt :: MessageSelector Int
> selectInt = selectMessage
>
> selectString :: MessageSelector String
> selectString = selectMessage
>
> selectIntOrString :: MessageSelector (Either Int String)
> selectIntOrString =
> Left $ selectTimeout| Right $ selectString
Instances
data ResumeProcess v where Source #
Every Process
action returns it's actual result wrapped in this type. It
will allow to signal errors as well as pass on normal results such as
incoming messages.
Interrupted :: Interrupt Recoverable -> ResumeProcess v | The current operation of the process was interrupted with a
|
ResumeWith :: a -> ResumeProcess a | The process may resume to do work, using the given result. |
Instances
newtype Serializer message Source #
Serialize a message
into a StrictDynamic
value to be sent via sendAnyMessage
.
This indirection allows, among other things, the composition of
Server
s.
Since: 0.24.1
MkSerializer | |
|
Instances
Contravariant Serializer Source # | |
Defined in Control.Eff.Concurrent.Process contramap :: (a -> b) -> Serializer b -> Serializer a # (>$) :: b -> Serializer b -> Serializer a # | |
Typeable message => Show (Serializer message) Source # | |
Defined in Control.Eff.Concurrent.Process showsPrec :: Int -> Serializer message -> ShowS # show :: Serializer message -> String # showList :: [Serializer message] -> ShowS # | |
NFData (Serializer message) Source # | |
Defined in Control.Eff.Concurrent.Process rnf :: Serializer message -> () # |
data StrictDynamic Source #
Data flows between Process
es via these messages.
This is just a newtype wrapper around Dynamic
.
The reason this type exists is to force construction through the code in this
module, which always evaluates a message to normal form before
sending it to another process.
Since: 0.22.0
Instances
Show StrictDynamic Source # | |
Defined in Control.Eff.Concurrent.Process showsPrec :: Int -> StrictDynamic -> ShowS # show :: StrictDynamic -> String # showList :: [StrictDynamic] -> ShowS # | |
NFData StrictDynamic Source # | |
Defined in Control.Eff.Concurrent.Process rnf :: StrictDynamic -> () # |
newtype ProcessDetails Source #
A multi-line text describing the current state of a process for debugging purposes.
Since: 0.24.1
Instances
newtype ProcessTitle Source #
A short title for a Process
for logging purposes.
Since: 0.24.1
Instances
data Process (r :: [Type -> Type]) b where Source #
The process effect is the basis for message passing concurrency. This effect describes an interface for concurrent, communicating isolated processes identified uniquely by a process-id.
Processes can raise exceptions that can be caught, exit gracefully or with an error, or be killed by other processes, with the option of ignoring the shutdown request.
Process Scheduling is implemented in different modules. All scheduler implementations should follow some basic rules:
- fair scheduling
- sending a message does not block
- receiving a message does block
- spawning a child blocks only a very moment
- a newly spawned process shall be scheduled before the parent process after
- the spawnRaw
- when the first process exists, all process should be killed immediately
FlushMessages :: Process r (ResumeProcess [StrictDynamic]) | Remove all messages from the process' message queue |
YieldProcess :: Process r (ResumeProcess ()) | In cooperative schedulers, this will give processing time to the scheduler. Every other operation implicitly serves the same purpose. Since: 0.12.0 |
SelfPid :: Process r (ResumeProcess ProcessId) | Return the current |
Spawn :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId) | Start a new process, the new process will execute an effect, the function
will return immediately with a |
SpawnLink :: ProcessTitle -> Eff (Process r ': r) () -> Process r (ResumeProcess ProcessId) | Start a new process, and Since: 0.12.0 |
Shutdown :: Interrupt NoRecovery -> Process r a | Shutdown the process; irregardless of the exit reason, this function never returns, |
SendShutdown :: ProcessId -> Interrupt NoRecovery -> Process r (ResumeProcess ()) | Shutdown another process immediately, the other process has no way of handling this! |
SendInterrupt :: ProcessId -> Interrupt Recoverable -> Process r (ResumeProcess ()) | Request that another a process interrupts. The targeted process is interrupted
and gets an |
SendMessage :: ProcessId -> StrictDynamic -> Process r (ResumeProcess ()) | Send a message to a process addressed by the |
ReceiveSelectedMessage :: forall r a. MessageSelector a -> Process r (ResumeProcess a) | Receive a message that matches a criteria.
This should block until an a message was received. The message is returned
as a |
MakeReference :: Process r (ResumeProcess Int) | Generate a unique |
Monitor :: ProcessId -> Process r (ResumeProcess MonitorReference) | Monitor another process. When the monitored process exits a
Since: 0.12.0 |
Demonitor :: MonitorReference -> Process r (ResumeProcess ()) | Remove a monitor. Since: 0.12.0 |
Link :: ProcessId -> Process r (ResumeProcess ()) | Connect the calling process to another process, such that
if one of the processes crashes (i.e. Since: 0.12.0 |
Unlink :: ProcessId -> Process r (ResumeProcess ()) | Unlink the calling process from the other process. Since: 0.12.0 |
UpdateProcessDetails :: ProcessDetails -> Process r (ResumeProcess ()) | Update the |
GetProcessState :: ProcessId -> Process r (ResumeProcess (Maybe (ProcessTitle, ProcessDetails, ProcessState))) | Get the |
Instances
fromProcessTitle :: Lens' ProcessTitle Text Source #
An isomorphism lens for the ProcessTitle
Since: 0.24.1
fromProcessDetails :: Lens' ProcessDetails Text Source #
An isomorphism lens for the ProcessDetails
Since: 0.24.1
toStrictDynamic :: (Typeable a, NFData a) => a -> StrictDynamic Source #
Deeply evaluate the given value and wrap it into a StrictDynamic
.
Since: 0.22.0
fromStrictDynamic :: Typeable a => StrictDynamic -> Maybe a Source #
Convert a StrictDynamic
back to a value.
Since: 0.22.0
unwrapStrictDynamic :: StrictDynamic -> Dynamic Source #
Convert a StrictDynamic
back to an unwrapped Dynamic
.
Since: 0.22.0
selectMessage :: Typeable t => MessageSelector t Source #
Create a message selector for a value that can be obtained by fromStrictDynamic
.
Since: 0.9.1
filterMessage :: Typeable a => (a -> Bool) -> MessageSelector a Source #
Create a message selector from a predicate.
Since: 0.9.1
selectMessageWith :: Typeable a => (a -> Maybe b) -> MessageSelector b Source #
Select a message of type a
and apply the given function to it.
If the function returns Just
The ReceiveSelectedMessage
function will
return the result (sans Maybe
).
Since: 0.9.1
selectDynamicMessage :: (StrictDynamic -> Maybe a) -> MessageSelector a Source #
Create a message selector.
Since: 0.9.1
selectAnyMessage :: MessageSelector StrictDynamic Source #
Create a message selector that will match every message. This is lazy
because the result is not force
ed.
Since: 0.9.1
toExitRecovery :: Interrupt r -> ExitRecovery Source #
Get the ExitRecovery
toExitSeverity :: Interrupt e -> ExitSeverity Source #
Get the ExitSeverity
of a Interrupt
.
interruptToExit :: Interrupt Recoverable -> Interrupt NoRecovery Source #
Return either ExitNormally
or interruptToExit
from a Recoverable
Interrupt
;
If the Interrupt
is NormalExitRequested
then return ExitNormally
isProcessDownInterrupt :: Maybe ProcessId -> Interrupt r -> Bool Source #
A predicate for linked process crashes.
provideInterruptsShutdown :: forall e a. Eff (Processes e) a -> Eff (SafeProcesses e) a Source #
Handle all Interrupt
s of an Processes
by
wrapping them up in interruptToExit
and then do a process Shutdown
.
handleInterrupts :: (HasCallStack, Member Interrupts r) => (Interrupt Recoverable -> Eff r a) -> Eff r a -> Eff r a Source #
Handle Interrupt
s arising during process operations, e.g.
when a linked process crashes while we wait in a receiveSelectedMessage
via a call to interrupt
.
tryUninterrupted :: (HasCallStack, Member Interrupts r) => Eff r a -> Eff r (Either (Interrupt Recoverable) a) Source #
Like handleInterrupts
, but instead of passing the Interrupt
to a handler function, Either
is returned.
Since: 0.13.2
logInterrupts :: forall r. (Member Logs r, HasCallStack, Member Interrupts r) => Eff r () -> Eff r () Source #
Handle interrupts by logging them with logProcessExit
and otherwise
ignoring them.
exitOnInterrupt :: (HasCallStack, HasProcesses r q) => Eff r a -> Eff r a Source #
Handle Interrupt
s arising during process operations, e.g.
when a linked process crashes while we wait in a receiveSelectedMessage
via a call to interrupt
.
provideInterrupts :: HasCallStack => Eff (Interrupts ': r) a -> Eff r (Either (Interrupt Recoverable) a) Source #
Handle Interrupt
s arising during process operations, e.g.
when a linked process crashes while we wait in a receiveSelectedMessage
via a call to interrupt
.
mergeEitherInterruptAndExitReason :: Either (Interrupt Recoverable) (Interrupt NoRecovery) -> Interrupt NoRecovery Source #
Wrap all (left) Interrupt
s into interruptToExit
and
return the (right) NoRecovery
Interrupt
s as is.
interrupt :: (HasCallStack, Member Interrupts r) => Interrupt Recoverable -> Eff r a Source #
Throw an Interrupt
, can be handled by handleInterrupts
or
exitOnInterrupt
or provideInterrupts
.
isCrash :: Interrupt x -> Bool Source #
A predicate for crashes. A crash happens when a process exits
with an Interrupt
other than ExitNormally
isRecoverable :: Interrupt x -> Bool Source #
A predicate for recoverable exit reasons. This predicate defines the
exit reasons which functions such as executeAndResume
fromSomeExitReason :: SomeExitReason -> Either (Interrupt NoRecovery) (Interrupt Recoverable) Source #
Partition a SomeExitReason
back into either a NoRecovery
or a Recoverable
Interrupt
toCrashReason :: Interrupt x -> Maybe Text Source #
Print a Interrupt
to Just
a formatted String
when isCrash
is True
.
This can be useful in combination with view patterns, e.g.:
logCrash :: Interrupt -> Eff e () logCrash (toCrashReason -> Just reason) = logError reason logCrash _ = return ()
Though this can be improved to:
logCrash = traverse_ logError . toCrashReason
logProcessExit :: forall e x. (Member Logs e, HasCallStack) => Interrupt x -> Eff e () Source #
Log the Interrupt
s
executeAndResume :: forall q r v. (HasSafeProcesses r q, HasCallStack) => Process q (ResumeProcess v) -> Eff r (Either (Interrupt Recoverable) v) Source #
Execute a and action and return the result;
if the process is interrupted by an error or exception, or an explicit
shutdown from another process, or through a crash of a linked process, i.e.
whenever the exit reason satisfies isRecoverable
, return the exit reason.
executeAndResumeOrExit :: forall r q v. (HasSafeProcesses r q, HasCallStack) => Process q (ResumeProcess v) -> Eff r v Source #
Execute a Process
action and resume the process, exit
the process when an Interrupts
was raised. Use executeAndResume
to catch
interrupts.
executeAndResumeOrThrow :: forall q r v. (HasProcesses r q, HasCallStack) => Process q (ResumeProcess v) -> Eff r v Source #
Execute a Process
action and resume the process, exit
the process when an Interrupts
was raised. Use executeAndResume
to catch
interrupts.
yieldProcess :: forall r q. (HasProcesses r q, HasCallStack) => Eff r () Source #
Use executeAndResumeOrExit
to execute YieldProcess
. Refer to YieldProcess
for more information.
sendMessage :: forall r q o. (HasProcesses r q, HasCallStack, Typeable o, NFData o) => ProcessId -> o -> Eff r () Source #
Send a message to a process addressed by the ProcessId
.
See SendMessage
.
The message will be reduced to normal form (rnf
) by/in the caller process.
sendAnyMessage :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> StrictDynamic -> Eff r () Source #
Send a Dynamic
value to a process addressed by the ProcessId
.
See SendMessage
.
sendShutdown :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Interrupt NoRecovery -> Eff r () Source #
Exit a process addressed by the ProcessId
. The process will exit,
it might do some cleanup, but is ultimately unrecoverable.
See SendShutdown
.
sendInterrupt :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Interrupt Recoverable -> Eff r () Source #
Interrupts a process addressed by the ProcessId
. The process might exit,
or it may continue.
| Like sendInterrupt
, but also return True
iff the process to exit exists.
spawn :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId Source #
Start a new process, the new process will execute an effect, the function
will return immediately with a ProcessId
. If the new process is
interrupted, the process will Shutdown
with the Interrupt
wrapped in interruptToExit
. For specific use cases it might be better to use
spawnRaw
.
spawn_ :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (Processes q) () -> Eff r () Source #
Like spawn
but return ()
.
spawnLink :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (Processes q) () -> Eff r ProcessId Source #
Start a new process, and immediately link to it.
Since: 0.12.0
spawnRaw :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r ProcessId Source #
Start a new process, the new process will execute an effect, the function
will return immediately with a ProcessId
. The spawned process has only the
raw SafeProcesses
effects. For non-library code spawn
might be better
suited.
spawnRaw_ :: forall r q. (HasCallStack, HasProcesses r q) => ProcessTitle -> Eff (SafeProcesses q) () -> Eff r () Source #
Like spawnRaw
but return ()
.
isProcessAlive :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r Bool Source #
Return True
if the process is alive.
Since: 0.12.0
getProcessState :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r (Maybe (ProcessTitle, ProcessDetails, ProcessState)) Source #
Return the ProcessTitle
, ProcessDetails
and ProcessState
,
for the given process, if the process is alive.
Since: 0.24.1
updateProcessDetails :: forall r q. (HasCallStack, HasProcesses r q) => ProcessDetails -> Eff r () Source #
Replace the ProcessDetails
of the process.
Since: 0.24.1
receiveAnyMessage :: forall r q. (HasCallStack, HasProcesses r q) => Eff r StrictDynamic Source #
Block until a message was received.
See ReceiveSelectedMessage
for more documentation.
receiveSelectedMessage :: forall r q a. (HasCallStack, Show a, HasProcesses r q) => MessageSelector a -> Eff r a Source #
Block until a message was received, that is not Nothing
after applying
a callback to it.
See ReceiveSelectedMessage
for more documentation.
receiveMessage :: forall a r q. (HasCallStack, Typeable a, NFData a, Show a, HasProcesses r q) => Eff r a Source #
Receive and cast the message to some Typeable
instance.
See ReceiveSelectedMessage
for more documentation.
This will wait for a message of the return type using receiveSelectedMessage
flushMessages :: forall r q. (HasCallStack, HasProcesses r q) => Eff r [StrictDynamic] Source #
Remove and return all messages currently enqueued in the process message queue.
Since: 0.12.0
receiveSelectedLoop :: forall r q a endOfLoopResult. (HasSafeProcesses r q, HasCallStack) => MessageSelector a -> (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult Source #
Enter a loop to receive messages and pass them to a callback, until the
function returns Just
a result.
Only the messages of the given type will be received.
If the process is interrupted by an exception of by a SendShutdown
from
another process, with an exit reason that satisfies isRecoverable
, then
the callback will be invoked with
, otherwise the
process will be exited with the same reason using Left
Interrupt
exitBecause
.
See also ReceiveSelectedMessage
for more documentation.
receiveAnyLoop :: forall r q endOfLoopResult. (HasSafeProcesses r q, HasCallStack) => (Either (Interrupt Recoverable) StrictDynamic -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult Source #
Like receiveSelectedLoop
but not selective.
See also selectAnyMessage
, receiveSelectedLoop
.
receiveLoop :: forall r q a endOfLoopResult. (HasSafeProcesses r q, HasCallStack, NFData a, Typeable a) => (Either (Interrupt Recoverable) a -> Eff r (Maybe endOfLoopResult)) -> Eff r endOfLoopResult Source #
Like receiveSelectedLoop
but refined to casting to a specific Typeable
using selectMessage
.
self :: (HasCallStack, HasSafeProcesses r q) => Eff r ProcessId Source #
Returns the ProcessId
of the current process.
makeReference :: (HasCallStack, HasProcesses r q) => Eff r Int Source #
Generate a unique Int
for the current process.
monitor :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r MonitorReference Source #
Monitor another process. When the monitored process exits a
ProcessDown
is sent to the calling process.
The return value is a unique identifier for that monitor.
There can be multiple monitors on the same process,
and a message for each will be sent.
If the process is already dead, the ProcessDown
message
will be sent immediately, without exit reason
Since: 0.12.0
demonitor :: forall r q. (HasCallStack, HasProcesses r q) => MonitorReference -> Eff r () Source #
Remove a monitor created with monitor
.
Since: 0.12.0
withMonitor :: (HasCallStack, HasProcesses r q) => ProcessId -> (MonitorReference -> Eff r a) -> Eff r a Source #
receiveWithMonitor :: (HasCallStack, HasProcesses r q, Typeable a, Show a) => ProcessId -> MessageSelector a -> Eff r (Either ProcessDown a) Source #
A MessageSelector
for receiving either a monitor of the
given process or another message.
Since: 0.12.0
becauseProcessIsDown :: ProcessDown -> Interrupt Recoverable Source #
Make an Interrupt
for a ProcessDown
message.
For example: doSomething >>= either (interrupt . becauseProcessIsDown) return
Since: 0.12.0
selectProcessDown :: MonitorReference -> MessageSelector ProcessDown Source #
A MessageSelector
for the ProcessDown
message of a specific
process.
The parameter is the value obtained by monitor
.
Since: 0.12.0
selectProcessDownByProcessId :: ProcessId -> MessageSelector ProcessDown Source #
A MessageSelector
for the ProcessDown
message. of a specific
process.
In contrast to selectProcessDown
this function matches the ProcessId
.
Since: 0.28.0
linkProcess :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r () Source #
Connect the calling process to another process, such that
if one of the processes crashes (i.e. isCrash
returns True
), the other
is shutdown with the Interrupt
LinkedProcessCrashed
.
Since: 0.12.0
unlinkProcess :: forall r q. (HasCallStack, HasProcesses r q) => ProcessId -> Eff r () Source #
Unlink the calling process from the other process.
Since: 0.12.0
exitBecause :: forall r q a. (HasCallStack, HasSafeProcesses r q) => Interrupt NoRecovery -> Eff r a Source #
Exit the process with a Interrupt
.
exitNormally :: forall r q a. (HasCallStack, HasSafeProcesses r q) => Eff r a Source #
Exit the process.
exitWithError :: forall r q a. (HasCallStack, HasSafeProcesses r q) => String -> Eff r a Source #
Exit the process with an error.
(NFData out, Typeable out, Show out) => Receiver | |
|
Instances
Contravariant Receiver Source # | |
Eq (Receiver o) Source # | |
Ord (Receiver o) Source # | |
Defined in Control.Eff.Concurrent.Process | |
Typeable protocol => Show (Receiver protocol) Source # | |
NFData (Receiver o) Source # | |
Defined in Control.Eff.Concurrent.Process |
sendToReceiver :: (NFData o, HasProcesses r q) => Receiver o -> o -> Eff r () Source #
class (Typeable protocol, Typeable embeddedProtocol) => HasPduPrism protocol embeddedProtocol where Source #
A class for Pdu
instances that embed other Pdu
.
This is a part of Embeds
provide instances for your
Pdu
s but in client code use the Embeds
constraint.
Instances of this class serve as proof to Embeds
that
a conversion into another Pdu
actually exists.
A Prism
for the embedded Pdu
is the center of this class
Laws: embeddedPdu = prism' embedPdu fromPdu
Since: 0.29.0
Nothing
embeddedPdu :: forall (result :: Synchronicity). Prism' (Pdu protocol result) (Pdu embeddedProtocol result) Source #
embedPdu :: forall (result :: Synchronicity). Pdu embeddedProtocol result -> Pdu protocol result Source #
fromPdu :: forall (result :: Synchronicity). Pdu protocol result -> Maybe (Pdu embeddedProtocol result) Source #
Instances
Typeable a => HasPduPrism a a Source # | |
(Typeable a1, Typeable a2) => HasPduPrism (a1, a2) a2 Source # | |
(Typeable a1, Typeable a2) => HasPduPrism (a1, a2) a1 Source # | |
(Typeable a1, Typeable a2, Typeable a3) => HasPduPrism (a1, a2, a3) a3 Source # | |
(Typeable a1, Typeable a2, Typeable a3) => HasPduPrism (a1, a2, a3) a2 Source # | |
(Typeable a1, Typeable a2, Typeable a3) => HasPduPrism (a1, a2, a3) a1 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4) => HasPduPrism (a1, a2, a3, a4) a4 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4) => HasPduPrism (a1, a2, a3, a4) a3 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4) => HasPduPrism (a1, a2, a3, a4) a2 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4) => HasPduPrism (a1, a2, a3, a4) a1 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4, HasPdu a5) => HasPduPrism (a1, a2, a3, a4, a5) a5 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4, HasPdu a5) => HasPduPrism (a1, a2, a3, a4, a5) a4 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4, HasPdu a5) => HasPduPrism (a1, a2, a3, a4, a5) a3 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4, HasPdu a5) => HasPduPrism (a1, a2, a3, a4, a5) a2 Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4, HasPdu a5) => HasPduPrism (a1, a2, a3, a4, a5) a1 Source # | |
type family ProtocolReply (s :: Synchronicity) where ... Source #
This type function takes an Pdu
and analysis the reply type, i.e. the Synchronicity
and evaluates to either t
for an
Pdu x (
or to '()' for an Synchronous
t)Pdu x
.Asynchronous
Since: 0.24.0
ProtocolReply (Synchronous t) = t | |
ProtocolReply Asynchronous = () |
data Synchronicity Source #
The (promoted) constructors of this type specify (at the type level) the
reply behavior of a specific constructor of an Pdu
instance.
Synchronous Type | Specify that handling a request is a blocking operation
with a specific return type, e.g. |
Asynchronous | Non-blocking, asynchronous, request handling |
type TangiblePdu p r = (Typeable p, Typeable r, Tangible (Pdu p r), HasPdu p) Source #
A Constraint
that bundles the requirements for the
Pdu
values of a protocol.
This ensures that Pdu
s can be strictly and deeply evaluated and shown
such that for example logging is possible.
Since: 0.24.0
type Embeds outer inner = (HasPduPrism outer inner, CheckEmbeds outer inner, HasPdu outer) Source #
A constraint that requires that the outer
Pdu
has a clause to
embed values from the inner
Pdu
.
Also, this constraint requires a HasPduPrism
instance, as a proof for
a possible conversion
of an embedded Pdu
value into to the enclosing Pdu
.
This generates better compiler error messages, when an embedding of a Pdu
into another.
This is provided by HasPdu
instances. The instances are required to
provide a list of embedded Pdu
values in EmbeddedPduList
.
Note that every type embeds itself, so Embeds x x
always holds.
Since: 0.29.1
class Typeable protocol => HasPdu (protocol :: Type) Source #
This type class and the associated data family defines the protocol data units (PDU) of a protocol.
A Protocol in the sense of a communication interface description between processes.
The first parameter is usually a user defined type that identifies the
protocol that uses the Pdu
s are. It maybe a phantom type.
The second parameter specifies if a specific constructor of an (GADT-like)
Pdu
instance is Synchronous
, i.e. returns a result and blocks the caller
or if it is Asynchronous
Example:
data BookShop deriving Typeable instance Typeable r => HasPdu BookShop r where data instance Pdu BookShop r where RentBook :: BookId -> Pdu BookShop ('Synchronous (Either RentalError RentalId)) BringBack :: RentalId -> Pdu BookShop 'Asynchronous deriving Typeable type BookId = Int type RentalId = Int type RentalError = String
Since: 0.25.1
type EmbeddedPduList protocol :: [Type] Source #
A type level list Protocol phantom types included in the associated Pdu
instance.
This is just a helper for better compiler error messages.
It relies on Embeds
to add the constraint HasPduPrism
.
Since: 0.29.0
data Pdu protocol (reply :: Synchronicity) Source #
The protocol data unit type for the given protocol.
Instances
Typeable p => HasPdu (Sup p) Source # | |
Tangible event => HasPdu (ObserverRegistry event) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Observer type EmbeddedPduList (ObserverRegistry event) :: [Type] Source # data Pdu (ObserverRegistry event) reply :: Type Source # | |
(HasPdu a1, HasPdu a2) => HasPdu (a1, a2) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
Tangible event => HasPdu (Observer event) Source # | |
(HasPdu a1, HasPdu a2, HasPdu a3) => HasPdu (a1, a2, a3) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4) => HasPdu (a1, a2, a3, a4) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
(HasPdu a1, HasPdu a2, HasPdu a3, HasPdu a4, HasPdu a5) => HasPdu (a1, a2, a3, a4, a5) Source # | |
Defined in Control.Eff.Concurrent.Protocol |
newtype Endpoint protocol Source #
A server process for protocol.
Protocols are represented by phantom types, which are used in different places to index type families and type class instances.
A Process
can send and receive any messages. An Endpoint
wraps around a ProcessId
and carries a phantom type to indicate
the kinds of messages accepted by the process.
As a metaphor, communication between processes can be thought of waiting for and sending protocol data units belonging to some protocol.
Instances
Eq (Endpoint protocol) Source # | |
Ord (Endpoint protocol) Source # | |
Defined in Control.Eff.Concurrent.Protocol compare :: Endpoint protocol -> Endpoint protocol -> Ordering # (<) :: Endpoint protocol -> Endpoint protocol -> Bool # (<=) :: Endpoint protocol -> Endpoint protocol -> Bool # (>) :: Endpoint protocol -> Endpoint protocol -> Bool # (>=) :: Endpoint protocol -> Endpoint protocol -> Bool # max :: Endpoint protocol -> Endpoint protocol -> Endpoint protocol # min :: Endpoint protocol -> Endpoint protocol -> Endpoint protocol # | |
Typeable protocol => Show (Endpoint protocol) Source # | |
NFData (Endpoint protocol) Source # | |
Defined in Control.Eff.Concurrent.Protocol | |
type ToPretty (Endpoint a :: Type) Source # | |
proxyAsEndpoint :: proxy protocol -> ProcessId -> Endpoint protocol Source #
asEndpoint :: forall protocol. ProcessId -> Endpoint protocol Source #
toEmbeddedEndpoint :: forall inner outer. Embeds outer inner => Endpoint outer -> Endpoint inner Source #
Convert an Endpoint
to an endpoint for an embedded protocol.
See Embeds
, fromEmbeddedEndpoint
.
Since: 0.25.1
fromEmbeddedEndpoint :: forall outer inner. HasPduPrism outer inner => Endpoint inner -> Endpoint outer Source #
Convert an Endpoint
to an endpoint for a server, that embeds the protocol.
See Embeds
, toEmbeddedEndpoint
.
Since: 0.25.1
fromEndpoint :: forall protocol protocol. Iso (Endpoint protocol) (Endpoint protocol) ProcessId ProcessId Source #
newtype ReplyTarget p r Source #
Target of a Call
reply.
This combines a RequestOrigin
with a Serializer
for a Reply
using Arg
.
There are to smart constructors for this type: replyTarget
and embeddedReplyTarget
.
Because of Arg
the Eq
and Ord
instances are implemented via
the RequestOrigin
instances.
Since: 0.26.0
MkReplyTarget (Arg (RequestOrigin p r) (Serializer (Reply p r))) |
Instances
Eq (ReplyTarget p r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Wrapper (==) :: ReplyTarget p r -> ReplyTarget p r -> Bool # (/=) :: ReplyTarget p r -> ReplyTarget p r -> Bool # | |
Ord (ReplyTarget p r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Wrapper compare :: ReplyTarget p r -> ReplyTarget p r -> Ordering # (<) :: ReplyTarget p r -> ReplyTarget p r -> Bool # (<=) :: ReplyTarget p r -> ReplyTarget p r -> Bool # (>) :: ReplyTarget p r -> ReplyTarget p r -> Bool # (>=) :: ReplyTarget p r -> ReplyTarget p r -> Bool # max :: ReplyTarget p r -> ReplyTarget p r -> ReplyTarget p r # min :: ReplyTarget p r -> ReplyTarget p r -> ReplyTarget p r # | |
Show (ReplyTarget p r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Wrapper showsPrec :: Int -> ReplyTarget p r -> ShowS # show :: ReplyTarget p r -> String # showList :: [ReplyTarget p r] -> ShowS # | |
NFData (ReplyTarget p r) Source # | |
Defined in Control.Eff.Concurrent.Protocol.Wrapper rnf :: ReplyTarget p r -> () # |
data RequestOrigin (proto :: Type) reply Source #
Instances
data Reply protocol reply where Source #
The wrapper around replies to Call
s.
Since: 0.15.0
Reply | |
|
data Request protocol where Source #
A wrapper sum type for calls and casts for the Pdu
s of a protocol
Since: 0.15.0
Call :: forall protocol reply. (Tangible reply, TangiblePdu protocol (Synchronous reply)) => RequestOrigin protocol reply -> Pdu protocol (Synchronous reply) -> Request protocol | |
Cast :: forall protocol. (TangiblePdu protocol Asynchronous, NFData (Pdu protocol Asynchronous)) => Pdu protocol Asynchronous -> Request protocol |
makeRequestOrigin :: (Typeable r, NFData r, HasProcesses e q0) => Eff e (RequestOrigin p r) Source #
Create a new, unique RequestOrigin
value for the current process.
Since: 0.24.0
toEmbeddedOrigin :: forall outer inner reply. Embeds outer inner => RequestOrigin outer reply -> RequestOrigin inner reply Source #
Turn an RequestOrigin
to an origin for an embedded request (See Embeds
).
This is useful of a server delegates the calls
and casts
for an embedded protocol
to functions, that require the Serializer
and RequestOrigin
in order to call
sendReply
.
See also embedReplySerializer
.
Since: 0.24.3
embedRequestOrigin :: forall outer inner reply. Embeds outer inner => RequestOrigin inner reply -> RequestOrigin outer reply Source #
Turn an embedded RequestOrigin
to a RequestOrigin
for the bigger request.
This is the inverse of toEmbeddedOrigin
.
This function is strict in all parameters.
Since: 0.24.2
embedReplySerializer :: forall outer inner reply. Embeds outer inner => Serializer (Reply outer reply) -> Serializer (Reply inner reply) Source #
Turn a Serializer
for a Pdu
instance that contains embedded Pdu
values
into a Reply
Serializer
for the embedded Pdu
.
This is useful of a server delegates the calls
and casts
for an embedded protocol
to functions, that require the Serializer
and RequestOrigin
in order to call
sendReply
.
See also toEmbeddedOrigin
.
Since: 0.24.2
sendReply :: (HasProcesses eff q, Tangible reply, Typeable protocol) => ReplyTarget protocol reply -> reply -> Eff eff () Source #
Answer a Call
by sending the reply value to the client process.
The ProcessId
, the RequestOrigin
and the Reply
Serializer
are
stored in the ReplyTarget
.
Since: 0.25.1
replyTarget :: Serializer (Reply p reply) -> RequestOrigin p reply -> ReplyTarget p reply Source #
Smart constructor for a ReplyTarget
.
To build a ReplyTarget
for an Embeds
instance use embeddedReplyTarget
.
Since: 0.26.0
replyTargetOrigin :: Lens' (ReplyTarget p reply) (RequestOrigin p reply) Source #
A simple Lens
for the RequestOrigin
of a ReplyTarget
.
Since: 0.26.0
replyTargetSerializer :: Lens' (ReplyTarget p reply) (Serializer (Reply p reply)) Source #
A simple Lens
for the Reply
Serializer
of a ReplyTarget
.
Since: 0.26.0
embeddedReplyTarget :: Embeds outer inner => Serializer (Reply outer reply) -> RequestOrigin outer reply -> ReplyTarget inner reply Source #
Smart constructor for an embedded ReplyTarget
.
This combines replyTarget
and toEmbeddedReplyTarget
.
Since: 0.26.0
toEmbeddedReplyTarget :: Embeds outer inner => ReplyTarget outer reply -> ReplyTarget inner reply Source #
Convert a ReplyTarget
to be usable for embedded replies.
This combines a toEmbeddedOrigin
with embedReplySerializer
to produce a
ReplyTarget
that can be passed to functions defined soley on an embedded protocol.
Since: 0.26.0
data TimerElapsed Source #
A value to be sent when timer started with startTimer
has elapsed.
Since: 0.12.0
Instances
Eq TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer (==) :: TimerElapsed -> TimerElapsed -> Bool # (/=) :: TimerElapsed -> TimerElapsed -> Bool # | |
Ord TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer compare :: TimerElapsed -> TimerElapsed -> Ordering # (<) :: TimerElapsed -> TimerElapsed -> Bool # (<=) :: TimerElapsed -> TimerElapsed -> Bool # (>) :: TimerElapsed -> TimerElapsed -> Bool # (>=) :: TimerElapsed -> TimerElapsed -> Bool # max :: TimerElapsed -> TimerElapsed -> TimerElapsed # min :: TimerElapsed -> TimerElapsed -> TimerElapsed # | |
Show TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer showsPrec :: Int -> TimerElapsed -> ShowS # show :: TimerElapsed -> String # showList :: [TimerElapsed] -> ShowS # | |
NFData TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer rnf :: TimerElapsed -> () # |
data TimerReference Source #
The reference to a timer started by startTimer
, required to stop
a timer via cancelTimer
.
Since: 0.12.0
Instances
A number of micro seconds.
Since: 0.12.0
Instances
Enum Timeout Source # | |
Eq Timeout Source # | |
Integral Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
Num Timeout Source # | |
Ord Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
Real Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer toRational :: Timeout -> Rational # | |
Show Timeout Source # | |
NFData Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer |
receiveAfter :: forall a r q. (Lifted IO q, HasCallStack, HasProcesses r q, Typeable a, NFData a, Show a) => Timeout -> Eff r (Maybe a) Source #
Wait for a message of the given type for the given time. When no message
arrives in time, return Nothing
. This is based on
receiveSelectedAfter
.
Since: 0.12.0
receiveSelectedAfter :: forall a r q. (Lifted IO q, HasCallStack, HasProcesses r q, Show a) => MessageSelector a -> Timeout -> Eff r (Either TimerElapsed a) Source #
Wait for a message of the given type for the given time. When no message
arrives in time, return Left
TimerElapsed
. This is based on
selectTimerElapsed
and startTimer
.
Since: 0.12.0
receiveSelectedWithMonitorAfter :: forall a r q. (Lifted IO q, HasCallStack, HasProcesses r q, Show a) => ProcessId -> MessageSelector a -> Timeout -> Eff r (Either (Either ProcessDown TimerElapsed) a) Source #
Like receiveWithMonitor
combined with receiveSelectedAfter
.
Since: 0.22.0
selectTimerElapsed :: TimerReference -> MessageSelector TimerElapsed Source #
A MessageSelector
matching TimerElapsed
messages created by
startTimer
.
Since: 0.12.0
sendAfter :: forall r q message. (Lifted IO q, HasCallStack, HasProcesses r q, Typeable message, NFData message) => ProcessId -> Timeout -> (TimerReference -> message) -> Eff r TimerReference Source #
Send a message to a given process after waiting. The message is created by
applying the function parameter to the TimerReference
, such that the
message can directly refer to the timer.
Since: 0.12.0
startTimer :: forall r q. (Lifted IO q, HasCallStack, HasProcesses r q) => Timeout -> Eff r TimerReference Source #
Start a new timer, after the time has elapsed, TimerElapsed
is sent to
calling process. The message also contains the TimerReference
returned by
this function. Use cancelTimer
to cancel the timer. Use
selectTimerElapsed
to receive the message using receiveSelectedMessage
.
To receive messages with guarded with a timeout see receiveAfter
.
Since: 0.12.0
cancelTimer :: forall r q. (Lifted IO q, HasCallStack, HasProcesses r q) => TimerReference -> Eff r () Source #
Cancel a timer started with startTimer
.
Since: 0.12.0
type EndpointReader o = Reader (Endpoint o) Source #
The reader effect for ProcessId
s for Pdu
s, see runEndpointReader
type HasEndpointReader o r = (Typeable o, Member (EndpointReader o) r) Source #
cast :: forall destination protocol r q. (HasCallStack, HasProcesses r q, HasPdu destination, HasPdu protocol, Tangible (Pdu destination Asynchronous), Embeds destination protocol) => Endpoint destination -> Pdu protocol Asynchronous -> Eff r () Source #
Send a request Pdu
that has no reply and return immediately.
The type signature enforces that the corresponding Pdu
clause is
Asynchronous
. The operation never fails, if it is important to know if the
message was delivered, use call
instead.
The message will be reduced to normal form (rnf
) in the caller process.
call :: forall result destination protocol r q. (HasProcesses r q, TangiblePdu destination (Synchronous result), TangiblePdu protocol (Synchronous result), Tangible result, Embeds destination protocol, HasCallStack) => Endpoint destination -> Pdu protocol (Synchronous result) -> Eff r result Source #
Send a request Pdu
and wait for the server to return a result value.
The type signature enforces that the corresponding Pdu
clause is
Synchronous
.
Always prefer callWithTimeout
over call
callWithTimeout :: forall result destination protocol r q. (HasProcesses r q, TangiblePdu destination (Synchronous result), TangiblePdu protocol (Synchronous result), Tangible result, Member Logs r, Lifted IO q, Lifted IO r, HasCallStack, Embeds destination protocol) => Endpoint destination -> Pdu protocol (Synchronous result) -> Timeout -> Eff r result Source #
Send an request Pdu
and wait for the server to return a result value.
The type signature enforces that the corresponding Pdu
clause is
Synchronous
.
If the server that was called dies, this function interrupts the
process with ProcessDown
.
If the server takes longer to reply than the given timeout, this
function interrupts the process with TimeoutInterrupt
.
Always prefer this function over call
Since: 0.22.0
runEndpointReader :: HasCallStack => Endpoint o -> Eff (EndpointReader o ': r) a -> Eff r a Source #
Run a reader effect that contains the one server handling a specific
Pdu
instance.
askEndpoint :: Member (EndpointReader o) e => Eff e (Endpoint o) Source #
Get the Endpoint
registered with runEndpointReader
.
callEndpointReader :: forall reply o r q. (HasEndpointReader o r, HasCallStack, Tangible reply, TangiblePdu o (Synchronous reply), HasProcesses r q, Embeds o o) => Pdu o (Synchronous reply) -> Eff r reply Source #
Like call
but take the Endpoint
from the reader provided by
runEndpointReader
.
When working with an embedded Pdu
use callSingleton
.
castEndpointReader :: forall o r q. (HasEndpointReader o r, HasProcesses r q, Tangible (Pdu o Asynchronous), HasCallStack, HasPdu o, Embeds o o) => Pdu o Asynchronous -> Eff r () Source #
Like cast
but take the Endpoint
from the reader provided by
runEndpointReader
.
When working with an embedded Pdu
use castSingleton
.
callSingleton :: forall outer inner reply q e. (HasCallStack, Member (EndpointReader outer) e, Embeds outer inner, Embeds outer outer, HasProcesses e q, TangiblePdu outer (Synchronous reply), TangiblePdu inner (Synchronous reply), Tangible reply) => Pdu inner (Synchronous reply) -> Eff e reply Source #
Like callEndpointReader
, uses embedPdu
to embed the value.
This function makes use of AmbigousTypes and TypeApplications.
When not working with an embedded Pdu
use callEndpointReader
.
Since: 0.25.1
castSingleton :: forall outer inner q e. (HasCallStack, Member (EndpointReader outer) e, Tangible (Pdu outer Asynchronous), HasProcesses e q, HasPdu outer, HasPdu inner, Embeds outer inner, Embeds outer outer) => Pdu inner Asynchronous -> Eff e () Source #
Like castEndpointReader
, but uses embedPdu
to embed the value.
This function makes use of AmbigousTypes and TypeApplications.
When not working with an embedded Pdu
use castEndpointReader
.
Since: 0.25.1
type ObserverRegistryState event = State (ObserverRegistry event) Source #
Alias for the effect that contains the observers managed by evalObserverRegistryState
data ObserverRegistry (event :: Type) Source #
A protocol for managing Observer
s, encompassing registration and de-registration of
Observer
s.
Since: 0.28.0
Instances
type CanObserve eventSink event = (Tangible event, Embeds eventSink (Observer event), HasPdu eventSink) Source #
Convenience type alias.
Since: 0.28.0
type IsObservable eventSource event = (Tangible event, Embeds eventSource (ObserverRegistry event), HasPdu eventSource) Source #
Convenience type alias.
Since: 0.28.0
data ObservationSink event Source #
The Information necessary to wrap an Observed
event to a process specific
message, e.g. the embedded Observer
Pdu
instance, and the MonitorReference
of
the destination process.
Since: 0.28.0
Instances
newtype Observer event Source #
A protocol to communicate Observed
events from a sources to many sinks.
A sink is any process that serves a protocol with a Pdu
instance that embeds
the Observer
Pdu via an HasPduPrism
instance.
This type has dual use, for one it serves as type-index for Pdu
, i.e.
HasPdu
respectively, and secondly it contains an ObservationSink
and
a MonitorReference
.
The ObservationSink
is used to serialize and send the Observed
events,
while the ProcessId
serves as key for internal maps.
Since: 0.28.0
MkObserver (Arg ProcessId (ObservationSink event)) |
Instances
registerObserver :: forall event eventSink eventSource r q. (HasCallStack, HasProcesses r q, IsObservable eventSource event, Tangible (Pdu eventSource Asynchronous), Tangible (Pdu eventSink Asynchronous), CanObserve eventSink event) => Endpoint eventSource -> Endpoint eventSink -> Eff r () Source #
And an Observer
to the set of recipients for all observations reported by observerRegistryNotify
.
Note that the observerRegistry are keyed by the observing process, i.e. a previous entry for the process
contained in the Observer
is overwritten. If you want multiple entries for a single process, just
combine several filter functions.
Since: 0.16.0
forgetObserver :: forall event eventSink eventSource r q. (HasProcesses r q, HasCallStack, Tangible (Pdu eventSource Asynchronous), Tangible (Pdu eventSink Asynchronous), IsObservable eventSource event, CanObserve eventSink event) => Endpoint eventSource -> Endpoint eventSink -> Eff r () Source #
Send the ForgetObserver
message
Since: 0.16.0
forgetObserverUnsafe :: forall event eventSource r q. (HasProcesses r q, HasCallStack, Tangible (Pdu eventSource Asynchronous), IsObservable eventSource event) => Endpoint eventSource -> ProcessId -> Eff r () Source #
Send the ForgetObserver
message, use a raw ProcessId
as parameter.
Since: 0.28.0
observerRegistryHandlePdu :: forall event q r. (HasCallStack, Typeable event, HasProcesses r q, Member (ObserverRegistryState event) r, Member Logs r) => Pdu (ObserverRegistry event) Asynchronous -> Eff r () Source #
Provide the implementation for the ObserverRegistry
Protocol, this handled RegisterObserver
and ForgetObserver
messages. It also adds the ObserverRegistryState
constraint to the effect list.
Since: 0.28.0
observerRegistryRemoveProcess :: forall event q r. (HasCallStack, Typeable event, HasProcesses r q, Member (ObserverRegistryState event) r, Member Logs r) => ProcessId -> Eff r Bool Source #
Remove the entry in the ObserverRegistry
for the ProcessId
and return True
if there was an entry, False
otherwise.
Since: 0.28.0
evalObserverRegistryState :: HasCallStack => Eff (ObserverRegistryState event ': r) a -> Eff r a Source #
Keep track of registered Observer
s.
Handle the ObserverRegistryState
effect, i.e. run evalState
on an emptyObserverRegistry
.
Since: 0.28.0
emptyObserverRegistry :: ObserverRegistry event Source #
The empty ObserverRegistryState
Since: 0.28.0
observerRegistryNotify :: forall event r q. (HasProcesses r q, Member (ObserverRegistryState event) r, Tangible event, HasCallStack) => event -> Eff r () Source #
Report an observation to all observers.
The process needs to evalObserverRegistryState
and to observerRegistryHandlePdu
.
Since: 0.28.0
type CaptureLogWriter = Writer LogMessage Source #
Alias for the Writer
that contains the captured LogMessage
s from CaptureLogs
.
type CaptureLogs a = LogWriterM CaptureLogWriter a Source #
runCaptureLogWriter :: Eff (CaptureLogWriter ': e) a -> Eff e (a, [LogMessage]) Source #
Run a Writer
for LogMessage
s.
Such a Writer
is needed to handle CaptureLogWriter
type LoggingAndIo = '[Logs, LogWriterReader (Lift IO), Lift IO] Source #
The concrete list of Eff
ects for logging with an IO based LogWriter
, and a LogWriterReader
.
mkLogWriterIO :: HasCallStack => (LogMessage -> IO ()) -> LogWriter (Lift IO) Source #
A LogWriter
that uses an IO
action to write the message.
This is just an alias for MkLogWriter
but with IO
as parameter. This reduces the need to
apply something to the extra type argument @IO
.
Example use cases for this function are the consoleLogWriter
and the ioHandleLogWriter
.
ioHandleLogWriter :: HasCallStack => Handle -> LogWriter (Lift IO) Source #
A LogWriter
that renders LogMessage
s to strings via renderLogMessageConsoleLog
and prints them to an Handle
using hPutStrLn
.
:: Lifted IO e | |
=> LogWriter (Lift IO) | The |
-> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a | |
-> Eff e a |
Enable logging to IO using the defaultIoLogWriter
.
Example:
exampleWithIoLogging :: IO () exampleWithIoLogging = runLift $ withIoLogging debugTraceLogWriter "my-app" local7 (lmSeverityIsAtLeast informationalSeverity) $ logInfo "Oh, hi there"
:: Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogWriter (Lift IO) | The IO based writer to decorate |
-> LogWriter (Lift IO) |
Decorate an IO based LogWriter
to fill out these fields in LogMessage
s:
- The messages will carry the given application name in the
lmAppName
field. - The
lmTimestamp
field contains the UTC time of the log event - The
lmHostname
field contains the FQDN of the current host - The
lmFacility
field contains the givenFacility
It works by using mappingLogWriterM
.
printLogMessage :: LogMessage -> IO () Source #
Render a LogMessage
but set the timestamp and thread id fields.
:: (Lifted IO e, MonadBaseControl IO (Eff e)) | |
=> FilePath | Path to the log-file. |
-> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a | |
-> Eff e a |
Enable logging to a file, with some LogMessage
fields preset
as described in withIoLogging
.
If the file or its directory does not exist, it will be created.
Example:
exampleWithFileLogging :: IO () exampleWithFileLogging = runLift $ withFileLogging "/var/log/my-app.log" "my-app" local7 allLogMessages $ logInfo "Oh, hi there"
To vary the LogWriter
use withIoLogging
.
Enable logging to a file.
If the file or its directory does not exist, it will be created. Example:
exampleWithFileLogWriter :: IO () exampleWithFileLogWriter = runLift $ withSomeLogging @IO $ withFileLogWriter "test.log" $ logInfo "Oh, hi there"
:: Lifted IO e | |
=> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a | |
-> Eff e a |
Enable logging via traceM
using the debugTraceLogWriter
, with some LogMessage
fields preset
as in withIoLogging
.
Log messages are rendered using renderLogMessageConsoleLog
.
Example:
exampleWithTraceLogging :: IO () exampleWithTraceLogging = runLift $ withTraceLogging "my-app" local7 allLogMessages $ logInfo "Oh, hi there"
withTraceLogWriter :: forall h e a. (Monad (LogWriterM h), LogsTo h e) => Eff e a -> Eff e a Source #
Enable logging via traceM
using the debugTraceLogWriter
. The
logging monad type can be any type with a Monad
instance.
Log messages are rendered using renderLogMessageConsoleLog
.
Example:
exampleWithTraceLogWriter :: IO () exampleWithTraceLogWriter = runLift $ withSomeLogging @IO $ withTraceLogWriter $ logInfo "Oh, hi there"
debugTraceLogWriter :: forall h. Monad (LogWriterM h) => LogMessageRenderer Text -> LogWriter h Source #
Write LogMessage
s via traceM
.
:: Lifted IO e | |
=> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a | |
-> Eff e a |
Enable logging to standard output
using the consoleLogWriter
, with some LogMessage
fields preset
as in withIoLogging
.
Log messages are rendered using renderLogMessageConsoleLog
.
Example:
exampleWithConsoleLogging :: IO () exampleWithConsoleLogging = runLift $ withConsoleLogging "my-app" local7 allLogMessages $ logInfo "Oh, hi there"
To vary the LogWriter
use withIoLogging
.
withConsoleLogWriter :: LogIo e => Eff e a -> Eff e a Source #
Enable logging to standard output
using the consoleLogWriter
.
Log messages are rendered using renderLogMessageConsoleLog
.
Example:
exampleWithConsoleLogWriter :: IO () exampleWithConsoleLogWriter = runLift $ withSomeLogging @IO $ withConsoleLogWriter $ logInfo "Oh, hi there"
consoleLogWriter :: LogWriter (Lift IO) Source #
Write LogMessage
s to standard output, formatted with printLogMessage
.
It uses stdoutLogWriter
with renderLogMessageConsoleLog
.
stdoutLogWriter :: LogMessageRenderer Text -> LogWriter (Lift IO) Source #
A LogWriter
that uses a LogMessageRenderer
to render, and putStrLn
to print it.
:: (Lifted IO e, MonadBaseControl IO (Eff e), Integral len) | |
=> LogWriter (Lift IO) | |
-> len | Size of the log message input queue. If the queue is full, message are dropped silently. |
-> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a | |
-> Eff e a |
This is a wrapper around withAsyncLogWriter
and withIoLogging
.
Example:
exampleWithAsyncLogging :: IO () exampleWithAsyncLogging = runLift $ withAsyncLogWriter consoleLogWriter (1000::Int) "my-app" local0 allLogMessages $ do logMsg "test 1" logMsg "test 2" logMsg "test 3"
:: (LogIo e, MonadBaseControl IO (Eff e), Integral len) | |
=> len | Size of the log message input queue. If the queue is full, message are dropped silently. |
-> Eff e a | |
-> Eff e a |
Move the current LogWriter
into its own thread.
A bounded queue is used to forward logs to the process.
If an exception is received, the logging process will be killed.
Log messages are deeply evaluated before being sent to the logger process, to prevent that lazy evaluation leads to heavy work being done in the logger process instead of the caller process.
Example:
exampleAsyncLogWriter :: IO () exampleAsyncLogWriter = runLift $ withLogging consoleLogWriter $ withAsyncLogWriter (1000::Int) $ do logMsg "test 1" logMsg "test 2" logMsg "test 3"
:: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) | |
=> (LogMessage -> Text) |
|
-> String | Hostname or IP |
-> String | Port e.g. |
-> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a | |
-> Eff e a |
Enable logging to a remote host via UDP, with some LogMessage
fields preset
as in withIoLogging
.
:: (LogIo e, MonadBaseControl IO (Eff e), HasCallStack) | |
=> (LogMessage -> Text) |
|
-> String | Hostname or IP |
-> String | Port e.g. |
-> Eff e b | |
-> Eff e b |
Enable logging to a (remote-) host via UDP.
withUnixSocketLogging Source #
:: (HasCallStack, MonadBaseControl IO (Eff e), Lifted IO e) | |
=> LogMessageRenderer Text |
|
-> FilePath | Path to the socket file |
-> Text | The default application name to put into the |
-> Facility | The default RFC-5424 facility to put into the |
-> LogPredicate | The inital predicate for log messages, there are some pre-defined in Control.Eff.Log.Message |
-> Eff (Logs ': (LogWriterReader (Lift IO) ': e)) a | |
-> Eff e a |
Enable logging to a unix domain socket, with some LogMessage
fields preset
as in withIoLogging
.
withUnixSocketLogWriter Source #
:: (LogIo e, MonadBaseControl IO (Eff e), HasCallStack) | |
=> LogMessageRenderer Text |
|
-> FilePath | Path to the socket file |
-> Eff e b | |
-> Eff e b |
Enable logging to a (remote-) host via UnixSocket.
foreverCheap :: Monad m => m a -> m () Source #
A version of forever
that hopefully tricks
GHC into not creating a space leak.
The intuition is, that we want to do something that is cheap, and hence
should be recomputed instead of shared.
Since: 0.4.0.0
replicateCheapM_ :: Monad m => Int -> m a -> m () Source #
A version of replicateM_
that hopefully tricks
GHC into not creating a space leak.
The intuition is, that we want to do something that is cheap, and hence
should be recomputed instead of shared.
Since: 0.4.0.0
Scheduler
schedule :: HasCallStack => LogWriter (Lift IO) -> Eff Effects a -> IO (Either (Interrupt NoRecovery) a) Source #
Run the Effects
using a single threaded, coroutine based, scheduler
from Control.Eff.Concurrent.Process.SingleThreadedScheduler.
Since: 0.25.0
defaultMain :: HasCallStack => Eff EffectsIo () -> IO () Source #
Execute a Process
using scheduleM
on top of Lift
IO
.
All logging is written to the console using consoleLogWriter
.
To use another LogWriter
use defaultMainWithLogWriter
instead.
defaultMainWithLogWriter :: HasCallStack => LogWriter (Lift IO) -> Eff EffectsIo () -> IO () Source #
type SafeEffects = SafeEffectsIo Source #
The effect list for Process
effects in the single threaded scheduler.
This is like SafeProcesses
, no Interrupts
are present.
See SafeEffectsIo
Since: 0.25.0
type BaseEffects = BaseEffectsIo Source #
type HasBaseEffects e = HasBaseEffectsIo e Source #