Skip to main content

PlacementTable

Struct PlacementTable 

Source
pub struct PlacementTable { /* private fields */ }
Expand description

Role to serving node.

Implementations§

Source§

impl PlacementTable

Source

pub fn new( node_id: impl Into<String>, dialer: Option<Arc<dyn MeshDialer>>, audit: Option<Arc<dyn ProxyAudit>>, ) -> Self

Table for node node_id. Without a dialer there is no mesh: only local instances resolve.

Source

pub fn with_advert_ttl(self, ttl: Duration) -> Self

Lifetime of a received advertisement (refreshed by each repeat).

Source

pub fn allow_remote_node(&self, role: &str, node: &str, on: bool)

Allow or stop allowing node to serve role to this node. This is the consumer-side counterpart of expose_to_mesh and the governed decision to send this node’s prompts to that node: without it no remote instance resolves, however it advertises.

Source

pub fn node_id(&self) -> &str

This node’s id.

Source

pub fn dialer(&self) -> Option<&Arc<dyn MeshDialer>>

The mesh dialer, when there is one.

Source

pub fn generation(&self) -> u64

Changes so far. A router cache keyed on this is never stale.

Source

pub fn subscribe(&self) -> Receiver<u64>

Wakes on every change (invalidate_all_placement on it).

Source

pub fn register_local( &self, role: &str, base: &str, model: Option<String>, api: &str, runtime: &str, ) -> Result<(), ProxyError>

Serve role from the loopback server at base. Refused when the endpoint is not http://<loopback ip>:<port>.

Source

pub fn deregister_local(&self, role: &str)

Stop serving role locally.

Source

pub async fn sync_local( &self, role: &str, rt: &InferRuntime, h: &InstanceHandle, ) -> SyncOutcome

Re-evaluate role against its adapter instance: reconcile (a dead managed server is restarted within its policy), probe, and serve it only while it answers.

Source

pub fn expose_to_mesh(&self, role: &str, on: bool)

Allow or stop serving role to mesh peers. Beyond loopback this is a governed decision (ADR-101 section 7): the caller decides, this records it.

Source

pub fn proxy_port(&self, role: &str) -> Option<u16>

The loopback proxy port registered for role (tests, status).

Source

pub fn set_proxy_port(&self, role: &str, port: u16)

The loopback proxy port that fronts role on this node.

Source

pub fn allow_mesh_peer(&self, role: &str, peer: &str, on: bool)

Allow or stop allowing peer to use this node’s instance of role (the serving-side counterpart of allow_remote_node). Exposure (expose_to_mesh) says the role may leave loopback at all; this says to whom. Default deny, audited.

Source

pub fn ingest_advertisement( &self, sender: &str, ad: &ServiceAdvertisement, ) -> bool

Take an infer.<role> advertisement received from sender, the node id the connection was verified as. Heard only when the advertisement is the sender’s own (ad.node_id == sender), the sender is an enforced-admission full node with a trusted scope, and this node allowlisted sender for the role. A repeat refreshes the TTL.

Source

pub fn remove_node(&self, node_id: &str)

A peer left or was revoked: forget what it advertised.

Source

pub fn resolve(&self, role: &str) -> Option<Target>

Where role is served: this node first, then an admitted peer. Admission is re-checked here, so a revoked peer stops resolving at once even before its entry is removed.

Source

pub fn local_for_peer(&self, role: &str, peer: &str) -> Option<MeshLocal>

The local instance of role, only when it is exposed to the mesh and peer is on the role’s serve allowlist: what that peer’s forwarded request may reach. Never a remote target, so a request cannot be bounced from node to node.

Source

pub fn mesh_peer_allowed(&self, role: &str, peer: &str) -> bool

Whether peer is on role’s serve allowlist.

Source

pub fn exposed_roles(&self) -> Vec<String>

Roles currently exposed to the mesh.

Source

pub fn peer_listed_any(&self, peer: &str) -> bool

Whether peer is on any role’s serve allowlist.

Source

pub fn base_url_for_role(&self, role: &str) -> Option<String>

Base URL for in-process consumers (PlacementResolver): the instance itself when it is local, this node’s loopback proxy when it is remote (the proxy speaks the mesh). None falls back.

Source

pub fn local_base_for_role(&self, role: &str) -> Option<String>

Base URL of a server for role on this node only (.../v1), for consumers that cannot go through the mesh.

Source

pub fn advertisement( &self, role: &str, now_secs: u64, ) -> Option<ServiceAdvertisement>

infer.<role> advertisement for a locally served role that is exposed to the mesh.

Source

pub fn advertisements(&self, now_secs: u64) -> Vec<ServiceAdvertisement>

Advertisements of every exposed local role.

Trait Implementations§

Source§

impl ServePolicy for PlacementTable

Source§

fn instance_for(&self, role: &str, peer: &str) -> Option<MeshLocal>

The loopback instance this node exposes to peer for role, or None (not exposed, or peer is not on the role’s serve allowlist).
Source§

fn peer_listed(&self, peer: &str) -> bool

Whether peer is on any role’s serve allowlist.

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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