Juvix imports
module arch.node.net.pub_sub_topic_behaviour;
import arch.node.net.pub_sub_topic_messages open;
import arch.node.net.pub_sub_topic_config open;
import arch.node.net.pub_sub_topic_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;
PubSubTopic Behaviour¶
Overview¶
A Pub/Sub Topic 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.
Action arguments¶
The action arguments are set by a guard
and passed to the action function as part of the GuardOutput.
PubSubTopicActionArguments¶
PubSubTopicActionArguments : Type := Unit;
Actions¶
Auxiliary Juvix code
PubSubTopicAction¶
PubSubTopicAction : Type :=
  Action
    PubSubTopicLocalCfg
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    PubSubTopicActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
PubSubTopicActionInput¶
PubSubTopicActionInput : Type :=
  ActionInput
    PubSubTopicLocalCfg
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    PubSubTopicActionArguments
    Anoma.Msg;
PubSubTopicActionEffect¶
PubSubTopicActionEffect : Type :=
  ActionEffect
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
PubSubTopicActionExec¶
PubSubTopicActionExec : Type :=
  ActionExec
    PubSubTopicLocalCfg
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    PubSubTopicActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
exampleReplyAction¶
Respond with a PubSubTopicMsgExampleResponse.
- State update
- The state remains unchanged.
- Messages to be sent
- A PubSubTopicMsgExampleReplymessage 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 : PubSubTopicActionInput) : Option PubSubTopicActionEffect := TODO;
Action Labels¶
exampleReplyActionLabel¶
exampleReplyActionLabel : PubSubTopicActionExec := Seq [exampleReplyAction];
Guards¶
Auxiliary Juvix code
PubSubTopicGuard¶
PubSubTopicGuard : Type :=
  Guard
    PubSubTopicLocalCfg
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    PubSubTopicActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
PubSubTopicGuardOutput¶
PubSubTopicGuardOutput : Type :=
  GuardOutput
    PubSubTopicLocalCfg
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    PubSubTopicActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
PubSubTopicGuardEval¶
PubSubTopicGuardEval : Type :=
  GuardEval
    PubSubTopicLocalCfg
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    PubSubTopicActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
exampleReplyGuard¶
Guard description (optional).
- Condition
- Message type is PubSubTopicMsgExampleRequest.
exampleReplyGuard
  (trigger : PubSubTopicTimestampedTrigger)
  (cfg : PubSubTopicCfg)
  (env : PubSubTopicEnv)
  : Option PubSubTopicGuardOutput := TODO;
Engine behaviour¶
PubSubTopicBehaviour¶
PubSubTopicBehaviour : Type :=
  EngineBehaviour
    PubSubTopicLocalCfg
    PubSubTopicLocalState
    PubSubTopicMailboxState
    PubSubTopicTimerHandle
    PubSubTopicActionArguments
    Anoma.Msg
    Anoma.Cfg
    Anoma.Env;
Instantiation¶
module pub_sub_topic_behaviour_example;
  exPubSubTopicBehaviour : PubSubTopicBehaviour :=
    mkEngineBehaviour@{
      guards := First [exampleReplyGuard];
    };
end;
Action Flowchart¶
exampleReply Flowchart¶
flowchart TD
  subgraph C[Conditions]
    CMsg>PubSubTopicMsgExampleRequest<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>PubSubTopicMsgExampleResponse<br/>argOne]
  endexampleReply flowchart