Skip to content
Juvix imports

module arch.node.net.pub_sub_topic;

import arch.node.net.pub_sub_topic_messages open public;
import arch.node.net.pub_sub_topic_config open public;
import arch.node.net.pub_sub_topic_environment open public;
import arch.node.net.pub_sub_topic_behaviour open public;
import arch.node.types.basics open;
import arch.node.types.engine open;
import arch.node.types.anoma as Anoma open;

open pub_sub_topic_config_example;
open pub_sub_topic_environment_example;
open pub_sub_topic_behaviour_example;

Pub/Sub Topic Engine

Purpose

A Pub/Sub Topic engine is responsible for topic-based publish/subscribe (pub/sub) message dissemination for a specific pub/sub topic.

The protocol allows a set of authorized publishers to publish messages in the topic, as well as local and remote engines to subscribe to it. Published messages are disseminated to all subscribers.

The engine instance name corresponds to the TopicID.

Components

Type

PubSubTopicEngine : Type :=
Engine
PubSubTopicLocalCfg
PubSubTopicLocalState
PubSubTopicMailboxState
PubSubTopicTimerHandle
PubSubTopicActionArguments
Anoma.Msg
Anoma.Cfg
Anoma.Env;

Instantiation

exPubSubTopicEngine : PubSubTopicEngine :=
mkEngine@{
cfg := exPubSubTopicCfg;
env := exPubSubTopicEnv;
behaviour := exPubSubTopicBehaviour;
};

Where exPubSubTopicCfg is defined as follows:

exPubSubTopicCfg : PubSubTopicCfg :=
mkEngineCfg@{
node := Curve25519PubKey "0xabcd1234";
name := "pub-sub-topic";
cfg := mkPubSubTopicLocalCfg;
};

exPubSubTopicEnv is defined as follows:

exPubSubTopicEnv : PubSubTopicEnv :=
mkEngineEnv@{
localState := mkPubSubTopicLocalState;
mailboxCluster := Map.empty;
acquaintances := Set.empty;
timers := [];
};

and exPubSubTopicBehaviour is defined as follows:

module pub_sub_topic_behaviour_example;
exPubSubTopicBehaviour : PubSubTopicBehaviour :=
mkEngineBehaviour@{
guards := First [exampleReplyGuard];
};
end;