haskell-distributed / haskell-distributed/distributed-process
Provide MxAgents with a dual state model
Open
@hyperthunk is already working on this.
Since Feb 13, 2017.
Feature Request
In Progress
- Dominant language
- Haskell
- Stars
- 751
- Forks
- 99
- Avg merge
- 45m
- Merged PRs (30d)
- 2
Description
It's often the case that whilst initialising an agent might need to wait on other actors, so we should either copy the init >>= serve model from client-server, or provide a dual state monadic environment so we don't have code like this...
data AgentState = Booting | ActualState { f1 = ..., f2 = ... }
-- and inside a listener
startIt = mxAgent agentId Booting [ mxSink handlePeersReady, mxSink handleEvent ]
where
handleEvent Booting = mxSkip
handleEvent ActualState{...} = ...
And worse still, have to worry about the boot state when you're buried in implementation code...
forwardToServer _ HBAgentBoot = liftMX terminate -- state invariant
forwardToServer ev' HBAgent{ hbServer = sPid }
= liftMX (send sPid ev') >> mxReady
handleRestarts _ HBAgentBoot = liftMX terminate -- state invariant
handleRestarts pid sta@HBAgent{ hbServer = sPid' }
| pid == sPid' = restartBoth sta
| otherwise = mxReady
On the other hand, we want this API to remain as simple as possible, since here we're providing service and utility, and policy belongs elsewhere.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.