pub struct AtlasRegistry { /* private fields */ }Expand description
In-memory state shared by all gRPC handlers (new + legacy). All ops go
through one of the typed async methods below. Arc<AtlasRegistry> is
cheap to clone; the interior RwLock serialises mutations.
contracts is loaded once at startup from <robonix_source>/capabilities/**
and is read-only for the lifetime of the process — handlers serve
QueryContract / ListContracts directly off it without locking.
Implementations§
Source§impl AtlasRegistry
impl AtlasRegistry
Sourcepub fn with_contracts(contracts: ContractRegistry) -> Self
pub fn with_contracts(contracts: ContractRegistry) -> Self
Construct a registry with an empty capability/channel state plus a
pre-loaded contract registry. Use this from main.rs once the
capabilities dir has been resolved.
pub fn contracts(&self) -> &ContractRegistry
Source§impl AtlasRegistry
impl AtlasRegistry
pub fn now_ms() -> u64
Sourcepub async fn register(
&self,
provider_id: &str,
kind: Kind,
namespace: &str,
capability_md_path: &str,
) -> Result<String, Status>
pub async fn register( &self, provider_id: &str, kind: Kind, namespace: &str, capability_md_path: &str, ) -> Result<String, Status>
Register a new capability instance, OR take over an existing
provider_id slot whose previous provider is gone. Empty provider_id triggers
Atlas-assigned ephemeral id. Returns the resolved id.
Takeover semantics — a re-Register on an existing provider_id is NOT an error. We assume the old process is dead (or about to be), so we drop its endpoints + state and reset last_heartbeat to now. The caller is then expected to redeclare capabilities with its own fresh endpoints. Without this, an orphan provider (heartbeat eviction hasn’t fired yet — 60s default) blocks every subsequent boot of the same package: rbnx waits for a “new” provider to appear in atlas, the python framework only retries register once and then quietly keeps going, and atlas keeps pointing consumers at the dead process’s endpoints. The previous “ALREADY_EXISTS” failure mode caught accidental dual deployments but the cure was worse than the disease — silent boot failures are nearly impossible to diagnose. If two live processes claim the same id, both will heartbeat into the same record and the latest declare wins; that case shows up as scattered/mysterious endpoint flips, which is at least visible.
Sourcepub async fn unregister(&self, provider_id: &str) -> bool
pub async fn unregister(&self, provider_id: &str) -> bool
Idempotent: returns true if a record was removed, false if the id
was unknown. Also drops any channels where this provider was the provider —
consumers will get NOT_FOUND on their next call and can re-discover.
Sourcepub async fn set_lifecycle_state(
&self,
provider_id: &str,
new_state: LifecycleState,
detail: &str,
) -> Result<LifecycleState, Status>
pub async fn set_lifecycle_state( &self, provider_id: &str, new_state: LifecycleState, detail: &str, ) -> Result<LifecycleState, Status>
Update the provider’s lifecycle state. Returns the previous value (or the inferred fallback when nothing’s been pushed yet) so callers can log “X went INACTIVE → ACTIVE” without a separate query. Validation is soft: illegal transitions log a warn but the new state is still stored. Strict validation will land later once telemetry confirms there are no spurious illegal transitions during atlas/provider startup-race conditions.
Sourcepub async fn heartbeat(&self, provider_id: &str) -> Result<u64, Status>
pub async fn heartbeat(&self, provider_id: &str) -> Result<u64, Status>
Updates last_heartbeat_ms to now. Returns the timestamp it set.
Sourcepub async fn declare(
&self,
provider_id: &str,
contract_id: &str,
transport: Transport,
proposed: &str,
params: TransportParams,
description: &str,
) -> Result<String, Status>
pub async fn declare( &self, provider_id: &str, contract_id: &str, transport: Transport, proposed: &str, params: TransportParams, description: &str, ) -> Result<String, Status>
Declare ONE transport for ONE contract on a registered provider. Returns
the authoritative endpoint string (may differ from proposed when
Atlas rewrote it to disambiguate on a mintable transport).
Sourcepub async fn query(
&self,
provider_id: &str,
kind: Kind,
contract: &str,
transport: Transport,
) -> Vec<CapabilityProvider>
pub async fn query( &self, provider_id: &str, kind: Kind, contract: &str, transport: Transport, ) -> Vec<CapabilityProvider>
Snapshot of registered Providers matching the given filters. Empty
provider_id / empty contract / Transport::Unspecified /
Kind::Unspecified mean “no filter on that field”. Each
returned record carries only the Capabilities that satisfy the
contract + transport filters.
pub async fn query_with_prefix( &self, provider_id: &str, kind: Kind, contract: &str, namespace_prefix: &str, transport: Transport, ) -> Vec<CapabilityProvider>
Sourcepub async fn connect(
&self,
consumer_id: &str,
provider_id: &str,
contract_id: &str,
transport: Transport,
) -> Result<(String, String, TransportParams), Status>
pub async fn connect( &self, consumer_id: &str, provider_id: &str, contract_id: &str, transport: Transport, ) -> Result<(String, String, TransportParams), Status>
Open a channel to one (provider provider, contract, transport). Atlas only providers the edge — the consumer dials the returned endpoint itself (each transport has its own connect protocol; atlas can’t dial generically). Returns the allocated channel handle and the full binding the consumer needs.
Sourcepub async fn disconnect(&self, channel_id: &str) -> bool
pub async fn disconnect(&self, channel_id: &str) -> bool
Idempotent: returns true if a channel was removed, false if
the id was unknown (already released, or auto-dropped when its
provider went away).
Sourcepub async fn capability_md(&self, provider_id: &str) -> Result<String, Status>
pub async fn capability_md(&self, provider_id: &str) -> Result<String, Status>
Read the provider’s CAPABILITY.md content. Returns “” when the provider registered without a path.
Sourcepub async fn inspect_json(&self) -> Result<String, Status>
pub async fn inspect_json(&self) -> Result<String, Status>
Debug-only JSON dump of the entire registry. Schema is unstable.
Trait Implementations§
Source§impl Debug for AtlasRegistry
impl Debug for AtlasRegistry
Source§impl Default for AtlasRegistry
impl Default for AtlasRegistry
Source§fn default() -> AtlasRegistry
fn default() -> AtlasRegistry
Auto Trait Implementations§
impl !Freeze for AtlasRegistry
impl !RefUnwindSafe for AtlasRegistry
impl Send for AtlasRegistry
impl Sync for AtlasRegistry
impl Unpin for AtlasRegistry
impl UnsafeUnpin for AtlasRegistry
impl !UnwindSafe for AtlasRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].