haskell-distributed / haskell-distributed/distributed-process

Provide MxAgents with a dual state model

Open
#307 0 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.