Juvix imports
module arch.node.engines.router_behaviour;
import arch.node.engines.router_messages open;
import arch.node.engines.router_config open;
import arch.node.engines.router_environment open;
import arch.node.types.basics open;
import arch.node.types.identities open;
import arch.node.types.messages open;
import arch.node.types.engine open;
import arch.node.types.anoma as Anoma open;
Router Behaviour¶
Overview¶
A router engine acts in the ways described on this page. The action labels correspond to the actions that can be performed by the engine. Using the action labels, we describe the effects of the actions.
Router Action Flowchart¶
exampleReply Flowchart¶
flowchart TD
  subgraph C[Conditions]
    CMsg>RouterMsgExampleRequest<br/>from local engine]
    CEnv[(exampleValue < 10)]
  end
  G(exampleReplyGuard)
  A(exampleReplyAction)
  C --> G -- *exampleReplyActionLabel* --> A --> E
  subgraph E[Effects]
    EEnv[(exampleValue := exampleValue + 1)]
    EMsg>RouterMsgExampleResponse<br/>argOne]
  endexampleReply flowchart
Action arguments¶
The action arguments are set by a guard
and passed to the action function as part of the GuardOutput.
RouterActionArguments¶
RouterActionArguments : Type := Unit;
Actions¶
Auxiliary Juvix code
RouterAction¶
RouterAction : Type :=
  Action
    RouterLocalCfg
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    RouterActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
RouterActionInput¶
RouterActionInput : Type :=
  ActionInput
    RouterLocalCfg
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    RouterActionArguments
    Anoma.Msg;
RouterActionEffect¶
RouterActionEffect : Type :=
  ActionEffect
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
RouterActionExec¶
RouterActionExec : Type :=
  ActionExec
    RouterLocalCfg
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    RouterActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
exampleReplyAction¶
Respond with a RouterMsgExampleReply.
- State update
- The state remains unchanged.
- Messages to be sent
- A RouterMsgExampleReplymessage with the data set byexampleReplyGuard.
- Engines to be spawned
- No engine is created by this action.
- Timer updates
- No timers are set or cancelled.
exampleReplyAction (input : RouterActionInput) : Option RouterActionEffect :=
  TODO;
Action Labels¶
exampleReplyActionLabel¶
exampleReplyActionLabel : RouterActionExec :=
  ActionExec.Seq [exampleReplyAction];
Guards¶
Auxiliary Juvix code
RouterGuard¶
RouterGuard : Type :=
  Guard
    RouterLocalCfg
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    RouterActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
RouterGuardOutput¶
RouterGuardOutput : Type :=
  GuardOutput
    RouterLocalCfg
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    RouterActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
RouterGuardEval¶
RouterGuardEval : Type :=
  GuardEval
    RouterLocalCfg
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    RouterActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
exampleReplyGuard¶
Guard description (optional).
- Condition
- Message type is RouterMsgExampleRequest.
exampleReplyGuard
  (trigger : RouterTimestampedTrigger)
  (cfg : RouterCfg)
  (env : RouterEnv)
  : Option RouterGuardOutput := TODO;
The Router behaviour¶
RouterBehaviour¶
RouterBehaviour : Type :=
  EngineBehaviour
    RouterLocalCfg
    RouterLocalState
    RouterMailboxState
    RouterTimerHandle
    RouterActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
Instantiation¶
module router_behaviour_example;
  exRouterBehaviour : RouterBehaviour :=
    EngineBehaviour.mk@{
      guards := GuardEval.First [exampleReplyGuard];
    };
end;