mcl_core_bridge (mcl_core v1.0.0)
View SourceThe macula mesh as a transport (docs/DESIGN.md §1.2, §3).
Everything mesh-shaped sits beside this module in src/bridge/: the DHT advertisement and the direct-dial call (mcl_core_capabilities), the D25 claim (mcl_core_claim), mesh pubsub (mcl_core_pubsub and its subscriptions), org membership, liveness and provider grants. This module is the face they show the contract through mcl_core_transport.
ONE NODE PER LAN CLUSTER IS THE BRIDGE (design §3, mcl-core#7). A node's role/0:
standalone -- the lan app env is off. The node is its own bridge and does everything on the mesh it did as mcl_om 1.9.0: pool, claim, and an advertisement for every capability it hosts. bridge -- the LAN is on and the bridge app env is true. The one node of its cluster that holds the mesh pool, the D25 claim and the advertisements. It advertises only the capabilities marked export => mesh (exported/1), from any node of the cluster, and forwards each mesh call to them into the LAN (mcl_core_bridge_inbound). member -- the LAN is on, bridge is false (the default). No pool, no claim, no advertisement. Its outbound mesh calls and publishes are relayed to the bridge node over distribution, so the mesh sees the bridge's identity. With no bridge in the cluster, they get the answer a node with no pool gives.
The bridge is found through the pg scope scope/0 (started on every LAN node by mcl_core_bridge_sup), where the bridge node's mcl_core_bridge_presence sits in the group bridge.
Summary
Functions
The group the bridge node's presence joins.
The cluster's bridge node, or none. Two bridges (a second one for failover, design §3): the lowest node name, the same on every member.
A capability call over the mesh: DHT lookup, then the provider's station (mcl_core_capabilities:call_capability/5). On a member, the bridge node makes it.
The names of the capabilities whose export is neither absent nor mesh; mcl_core_capabilities:register/3 refuses them, so a typo is not silently a capability the mesh never sees.
Whether a capability is exported to the mesh: export => mesh.
The mesh pool handle, or {error, no_client} when this node runs none: no seeds, or a member.
Whether this node itself talks to the mesh: every role but member.
A publish on the mesh (mcl_core_pubsub:mesh_publish/3). On a member, the bridge node publishes it.
This node's part in its cluster's mesh traffic (see the moduledoc). A bridge value other than a boolean raises, naming it.
The pg scope the bridge is found in.
Start function of the mesh-pool child mcl_core_sup includes on a node on the mesh with pinned seeds. Runs strictly after mcl_core_identity, so the node key is already resolved.
Types
Functions
-spec bridge_group() -> atom().
The group the bridge node's presence joins.
-spec bridge_node() -> {ok, node()} | none.
The cluster's bridge node, or none. Two bridges (a second one for failover, design §3): the lowest node name, the same on every member.
-spec call_capability(binary(), binary(), term(), pos_integer(), map()) -> {ok, term()} | {error, term()}.
A capability call over the mesh: DHT lookup, then the provider's station (mcl_core_capabilities:call_capability/5). On a member, the bridge node makes it.
-spec export_verdict([mcl_core_service:capability()]) -> ok | {error, {export_unknown, [binary()]}}.
The names of the capabilities whose export is neither absent nor mesh; mcl_core_capabilities:register/3 refuses them, so a typo is not silently a capability the mesh never sees.
-spec exported(mcl_core_service:capability()) -> boolean().
Whether a capability is exported to the mesh: export => mesh.
-spec macula_client() -> {ok, pid()} | {error, no_client}.
The mesh pool handle, or {error, no_client} when this node runs none: no seeds, or a member.
-spec on_mesh() -> boolean().
Whether this node itself talks to the mesh: every role but member.
A publish on the mesh (mcl_core_pubsub:mesh_publish/3). On a member, the bridge node publishes it.
-spec role() -> role().
This node's part in its cluster's mesh traffic (see the moduledoc). A bridge value other than a boolean raises, naming it.
-spec scope() -> atom().
The pg scope the bridge is found in.
Start function of the mesh-pool child mcl_core_sup includes on a node on the mesh with pinned seeds. Runs strictly after mcl_core_identity, so the node key is already resolved.