Skip to main content

GlobalRegistryServer

Struct GlobalRegistryServer 

Source
pub struct GlobalRegistryServer {
    pub config: GlobalRegistryServerConfig,
    pub seed: u64,
    pub entries: HashMap<PeerId, (u64, Address)>,
    /* private fields */
}
Expand description

Server half of GlobalRegistry. Maintains PeerId → (expires_at_ns, source_address) over the announced cohort and exposes the cohort as a bb_runtime::contracts::PeerSelector source. Eviction is lazy: Sample / CurrentView drop entries whose expires_at_ns has elapsed before consulting the registry.

Fields§

§config: GlobalRegistryServerConfig

Configurable TTL bounds + heartbeat policy.

§seed: u64

RNG seed for deterministic Sample selection. Persisted so a restored server samples consistently.

§entries: HashMap<PeerId, (u64, Address)>

Registry: PeerId → (expires_at_ns, source_address). Restored alongside seed so cohort continuity survives snapshot/restore.

Implementations§

Source§

impl GlobalRegistryServer

Source

pub fn new(seed: u64) -> Self

Construct a fresh server with the default TTL/heartbeat policy and seed driving deterministic Sample selection.

Source

pub fn with_config(seed: u64, config: GlobalRegistryServerConfig) -> Self

Construct with an explicit config override.

Source

pub fn heartbeat_interval_ns(&self) -> u64

Server-derived heartbeat interval. Integer division on default_ttl_ns / 3 gives the client three windows to refresh before eviction.

Trait Implementations§

Source§

impl AnyComponent for GlobalRegistryServer

Source§

fn as_any(&self) -> &dyn Any

Downcast view - immutable.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast view - mutable.
Source§

impl Bootstrap for GlobalRegistryServer

Source§

type Error = Infallible

Library-maker-defined error type. Must satisfy the standard engine error bounds so the framework can box it into the dispatch error channel.
Source§

fn bootstrap(&mut self, _ctx: &mut BootstrapCtx) -> Result<(), Self::Error>

Run one-shot setup. Default no-op so Components without an initialization phase need no boilerplate. Authors override to mmap state, allocate backend tensors, prime calibration buffers, etc.
Source§

impl Clone for GlobalRegistryServer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConcreteComponent for GlobalRegistryServer

Source§

const TYPE_NAME: &'static str = "GlobalRegistryServer"

Stable identifier. Convention: <crate>::<TypeName>.
Source§

const PACKAGE: ComponentPackage = ::bytesandbrains::concrete::ComponentPackage::Application

Origin tag; defaults to Application.
Source§

const DEPENDENCIES: &'static [DependencyDecl]

Sibling components this depends on. Populated by the bb::Concrete derive from #[bb::depends(...)].
Source§

type Config = ()

Per-deployment config. Use () for stateless concretes.
Source§

type Error = Infallible

Error from Self::new; use Infallible if construction can’t fail.
Source§

fn new(_config: &Self::Config) -> Result<Self, Self::Error>

Construct from &Self::Config. Install calls this once per slot.
Source§

fn serialize(&self) -> Vec<u8>

Serialize state to bytes, including config-derived fields.
Source§

fn restore(bytes: &[u8]) -> Result<Self, RestoreError>

Reconstruct from serialize output.
Source§

impl Debug for GlobalRegistryServer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GlobalRegistryServer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for GlobalRegistryServer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PeerSelector for GlobalRegistryServer

Source§

type Error = OpError

Library-maker-defined error type.
Source§

fn select( &mut self, ctx: &mut RuntimeResourceRef<'_>, params: SelectParams, _completion: CompletionHandle<Vec<PeerId>, Self::Error>, ) -> ContractResponse<Vec<PeerId>, Self::Error>

Generic selection — params carries selector-specific config. Concrete impls handle the variants they support and fail the unsupported ones via ContractResponse::Now carrying an error. ctx exposes ctx.peers.addresses (the framework’s AddressBook), the engine’s per-op runtime surface, and ctx.dependency::<T>(slot) for reaching any concrete bound via #[depends(...)].
Source§

fn current_view( &mut self, ctx: &mut RuntimeResourceRef<'_>, _completion: CompletionHandle<Vec<PeerId>, Self::Error>, ) -> ContractResponse<Vec<PeerId>, Self::Error>

Snapshot the current view of known peers (owned snapshot — async serialization needs owned values).
Source§

fn sample( &mut self, ctx: &mut RuntimeResourceRef<'_>, n: u32, completion: CompletionHandle<Vec<PeerId>, Self::Error>, ) -> ContractResponse<Vec<PeerId>, Self::Error>

Sample n peers from the current view. Calls land on select(SelectParams::Random { n }) by default. Concrete impls may override to keep an optimized fast path.
Source§

impl PeerSelectorRuntime for GlobalRegistryServer

Source§

type Error = OpError

Peer-sampling-impl-specific error type.
Source§

fn atomic_opset(&self) -> AtomicOpsetDecl

Atomic-op opset this impl owns.
Source§

fn dispatch_atomic( &mut self, op_type: &str, _inputs: &[(&str, &dyn SlotValue)], _ctx: &mut RuntimeResourceRef<'_>, ) -> Result<DispatchResult, Self::Error>

Rust-dispatch entry point for atomic ops.
Source§

impl ProtocolRuntime for GlobalRegistryServer

Source§

type Error = OpError

Protocol-impl-specific error type.
Source§

fn atomic_opset(&self) -> AtomicOpsetDecl

Atomic-op opset this protocol declares. Both inbound envelope routing AND user-graph DSL ops register here.
Source§

fn dispatch_atomic( &mut self, op_type: &str, inputs: &[(&str, &dyn SlotValue)], ctx: &mut RuntimeResourceRef<'_>, ) -> Result<DispatchResult, OpError>

Single dispatch entry. For inbound envelopes the framework synthesizes inputs from the wire envelope: Read more
Source§

impl Serialize for GlobalRegistryServer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedComponent for T
where T: Any + Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SlotValue for T

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Downcast surface — recover the concrete type.
Source§

fn into_any_boxed(self: Box<T>) -> Box<dyn Any + Sync + Send>

Repackage Box<dyn SlotValue> as Box<dyn Any> for Box::downcast. Required because the SlotValue and Any vtables are distinct even though SlotValue: Any.
Source§

fn clone_boxed(&self) -> Box<dyn SlotValue>

Polymorphic clone preserving the concrete type.
Source§

fn to_wire_bytes(&self) -> Result<Vec<u8>, SlotValueError>

Wire-boundary encode (bincode + serde). Local forwarding uses clone_boxed instead.
Source§

fn type_hash(&self) -> u64

Stable cross-Node type discriminator. FNV-1a of std::any::type_name::<T>(); receiver decodes only on a matching hash.
Source§

fn runtime_type(&self) -> &'static TypeNode

Runtime TypeNode for this value. Returns the leaf registered via [register_type_node!] or TYPE_ANY. Consulted at wire boundaries + TypeSolver seeding; the atomic-dispatch hot path uses compile-time-stamped closures.
Source§

fn charged_bytes(&self) -> usize

Bytes the carrier owes against NodeConfig::ingress_byte_budget. Slot-table eviction calls this to release the charge. Default 0 — only ingress-derived carriers register a non-zero resolver via [register_charged_bytes!].
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more