Safe Haskell | None |
---|---|
Language | Haskell2010 |
Core daemon logic, Internal
Synopsis
- runAgent :: forall (tag :: AgentTag) r. AgentName tag => Member (Tagged tag Agent) r => Event -> Sem r ()
- broadcast :: Members Agents r => Member Log r => Event -> Sem r ()
- inRecent :: Time -> Event -> Seq Event -> Bool
- appendIfValid :: Time -> Event -> Seq Event -> Maybe (Seq Event)
- insertEvent :: Members [AtomicState (Seq Event), ChronosTime] r => Event -> Sem r Bool
- truncateLog :: Member (AtomicState (Seq Event)) r => Int -> Sem r (Maybe Int)
- receiveEvent :: Members Agents r => Members [AtomicState (Seq Event), ChronosTime, Log] r => Maybe Int -> Event -> Sem r ()
- loadEvent :: Members [AtomicState (Seq Event), ChronosTime, Log] r => Int -> Sem r (Maybe Event)
- isNetworkCycle :: Member (Reader InstanceName) r => Event -> Sem r Bool
- interpretHistory :: Members Agents r => Members [Reader InstanceName, AtomicState (Seq Event), ChronosTime, Log] r => Maybe Int -> InterpreterFor History r
Documentation
runAgent :: forall (tag :: AgentTag) r. AgentName tag => Member (Tagged tag Agent) r => Event -> Sem r () Source #
Send an event to an agent unless it was published by that agent.
broadcast :: Members Agents r => Member Log r => Event -> Sem r () Source #
Send an event to all agents.
inRecent :: Time -> Event -> Seq Event -> Bool Source #
Whether there was an event within the last second that contained the same text as the current event.
appendIfValid :: Time -> Event -> Seq Event -> Maybe (Seq Event) Source #
Append an event to the history unless the newest event contains the same text or there was an event within the last second that contained the same text, to avoid clobbering due to cycles induced by external programs.
insertEvent :: Members [AtomicState (Seq Event), ChronosTime] r => Event -> Sem r Bool Source #
Add an event to the history unless it is a duplicate.
truncateLog :: Member (AtomicState (Seq Event)) r => Int -> Sem r (Maybe Int) Source #
Remove excess entries from the front of the Seq
, given a maximum number of entries.
Return the number of dropped entries.
receiveEvent :: Members Agents r => Members [AtomicState (Seq Event), ChronosTime, Log] r => Maybe Int -> Event -> Sem r () Source #
Process an event received from outside.
loadEvent :: Members [AtomicState (Seq Event), ChronosTime, Log] r => Int -> Sem r (Maybe Event) Source #
Re-broadcast an older event from the history at the given index (ordered by increasing age) and move it to the end of the history.
isNetworkCycle :: Member (Reader InstanceName) r => Event -> Sem r Bool Source #
In the unlikely case of a remote host sending an event back to this instance and not updating the sender, this will
be True
.
interpretHistory :: Members Agents r => Members [Reader InstanceName, AtomicState (Seq Event), ChronosTime, Log] r => Maybe Int -> InterpreterFor History r Source #
Interpret History
as AtomicState
, broadcasting to agents.