Juvix imports
module arch.node.net.router;
import arch.node.net.router_messages open;
import arch.node.net.router_config open;
import arch.node.net.router_environment open;
import arch.node.net.router_behaviour open;
import arch.node.types.basics open;
import arch.node.types.engine open;
import arch.node.types.anoma as Anoma open;
open router_config_example;
open router_environment_example;
open router_behaviour_example;
Router Engine¶
Purpose¶
The Router engine is responsible for
spawning a Node Proxy instance for each remote node,
and a Pub/Sub Topic instance for each pub/sub topic.
It maintains a database of known NodeAdvert
and TopicAdvert
messages.
Engine Components¶
Type¶
RouterEngine : Type :=
Engine
RouterLocalCfg
RouterLocalState
RouterMailboxState
RouterTimerHandle
RouterActionArguments
Anoma.Msg
Anoma.Cfg
Anoma.Env;
Instantiation¶
exRouterEngine : RouterEngine :=
mkEngine@{
cfg := exRouterCfg;
env := exRouterEnv;
behaviour := exRouterBehaviour;
};
Where exRouterCfg
is defined as follows:
exRouterCfg : RouterCfg :=
mkEngineCfg@{
node := Curve25519PubKey "0xabcd1234";
name := "router";
cfg := mkRouterLocalCfg;
};
exRouterEnv
is defined as follows:
exRouterEnv : RouterEnv :=
mkEngineEnv@{
localState := mkRouterLocalState;
mailboxCluster := Map.empty;
acquaintances := Set.empty;
timers := [];
};
and exRouterBehaviour
is defined as follows:
module router_behaviour_example;
exRouterBehaviour : RouterBehaviour :=
mkEngineBehaviour@{
guards := First [exampleReplyGuard];
};
end;