hecate_om_capabilities (hecate_om v0.12.0)
View SourceAdvertises a service's capabilities as signed procedure advertisements in the mesh DHT, and resolves other services' capabilities from the same DHT.
Replaces the former pubsub _mesh.cap.announce summary broadcast: discovery is record-based now (direct-dial discovery, plan Slice 2). For each capability the service exposes, this worker writes a signed procedure_advertisement keyed at SHA-256(procedure_uri), naming the service (advertiser) and one station it is reachable through (serving_station). Records are re-asserted on a timer because DHT records expire (and the timer also retries the initial write until the pool and a station link are up).
lookup/1 resolves a capability by name: derive the same procedure key, read every advertisement stored there, verify each signature, return the {advertiser, serving_station} set. A consumer then dials one of those stations (Slice 4+).
Signing needs the service's stable keypair (hecate_om_identity:keypair/0); an ephemeral service cannot sign and is correctly not advertised.
Summary
Functions
Call a capability by name over the DIRECT-DIAL data path: resolve the providers of CapName (their procedure_advertisement records), resolve one provider's serving station to a dialable endpoint, dial it directly and issue the CALL there. On failure (unresolvable endpoint, dead station, error reply) fail over to the next provider.
Explicit-pool form (testable without hecate_om_identity): resolve providers, then dial + call each in turn until one answers.
Resolve a capability by name to the providers advertising it. {ok, [#{advertiser := Pubkey, serving_station := Pubkey}]}. Empty when nothing is advertised or the mesh is unreachable.
Functions
-spec build_advertisement(macula_identity:key_pair(), binary(), hecate_om_service:capability(), macula_identity:pubkey()) -> map().
-spec call_capability(binary(), term(), pos_integer()) -> {ok, term()} | {error, term()}.
Call a capability by name over the DIRECT-DIAL data path: resolve the providers of CapName (their procedure_advertisement records), resolve one provider's serving station to a dialable endpoint, dial it directly and issue the CALL there. On failure (unresolvable endpoint, dead station, error reply) fail over to the next provider.
The CALL uses the raw CapName as the procedure (realm-scoped by Realm), matching how a provider serves it via macula:advertise. Runs in the caller's process (not the capabilities gen_server), so a slow mesh never blocks capability registration.
-spec call_capability(pid(), binary(), binary(), term(), pos_integer()) -> {ok, term()} | {error, term()}.
Explicit-pool form (testable without hecate_om_identity): resolve providers, then dial + call each in turn until one answers.
Resolve a capability by name to the providers advertising it. {ok, [#{advertiser := Pubkey, serving_station := Pubkey}]}. Empty when nothing is advertised or the mesh is unreachable.