pub struct PlacementTable { /* private fields */ }Expand description
Role to serving node.
Implementations§
Source§impl PlacementTable
impl PlacementTable
Sourcepub fn new(
node_id: impl Into<String>,
dialer: Option<Arc<dyn MeshDialer>>,
audit: Option<Arc<dyn ProxyAudit>>,
) -> Self
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.
Sourcepub fn with_advert_ttl(self, ttl: Duration) -> Self
pub fn with_advert_ttl(self, ttl: Duration) -> Self
Lifetime of a received advertisement (refreshed by each repeat).
Sourcepub fn allow_remote_node(&self, role: &str, node: &str, on: bool)
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.
Sourcepub fn dialer(&self) -> Option<&Arc<dyn MeshDialer>>
pub fn dialer(&self) -> Option<&Arc<dyn MeshDialer>>
The mesh dialer, when there is one.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Changes so far. A router cache keyed on this is never stale.
Sourcepub fn subscribe(&self) -> Receiver<u64>
pub fn subscribe(&self) -> Receiver<u64>
Wakes on every change (invalidate_all_placement on it).
Sourcepub fn register_local(
&self,
role: &str,
base: &str,
model: Option<String>,
api: &str,
runtime: &str,
) -> Result<(), ProxyError>
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>.
Sourcepub fn deregister_local(&self, role: &str)
pub fn deregister_local(&self, role: &str)
Stop serving role locally.
Sourcepub async fn sync_local(
&self,
role: &str,
rt: &InferRuntime,
h: &InstanceHandle,
) -> SyncOutcome
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.
Sourcepub fn expose_to_mesh(&self, role: &str, on: bool)
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.
Sourcepub fn proxy_port(&self, role: &str) -> Option<u16>
pub fn proxy_port(&self, role: &str) -> Option<u16>
The loopback proxy port registered for role (tests, status).
Sourcepub fn set_proxy_port(&self, role: &str, port: u16)
pub fn set_proxy_port(&self, role: &str, port: u16)
The loopback proxy port that fronts role on this node.
Sourcepub fn allow_mesh_peer(&self, role: &str, peer: &str, on: bool)
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.
Sourcepub fn ingest_advertisement(
&self,
sender: &str,
ad: &ServiceAdvertisement,
) -> bool
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.
Sourcepub fn remove_node(&self, node_id: &str)
pub fn remove_node(&self, node_id: &str)
A peer left or was revoked: forget what it advertised.
Sourcepub fn resolve(&self, role: &str) -> Option<Target>
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.
Sourcepub fn local_for_peer(&self, role: &str, peer: &str) -> Option<MeshLocal>
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.
Sourcepub fn mesh_peer_allowed(&self, role: &str, peer: &str) -> bool
pub fn mesh_peer_allowed(&self, role: &str, peer: &str) -> bool
Whether peer is on role’s serve allowlist.
Sourcepub fn exposed_roles(&self) -> Vec<String>
pub fn exposed_roles(&self) -> Vec<String>
Roles currently exposed to the mesh.
Sourcepub fn peer_listed_any(&self, peer: &str) -> bool
pub fn peer_listed_any(&self, peer: &str) -> bool
Whether peer is on any role’s serve allowlist.
Sourcepub fn base_url_for_role(&self, role: &str) -> Option<String>
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.
Sourcepub fn local_base_for_role(&self, role: &str) -> Option<String>
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.
Sourcepub fn advertisement(
&self,
role: &str,
now_secs: u64,
) -> Option<ServiceAdvertisement>
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.
Sourcepub fn advertisements(&self, now_secs: u64) -> Vec<ServiceAdvertisement>
pub fn advertisements(&self, now_secs: u64) -> Vec<ServiceAdvertisement>
Advertisements of every exposed local role.
Trait Implementations§
Source§impl ServePolicy for PlacementTable
impl ServePolicy for PlacementTable
Auto Trait Implementations§
impl !Freeze for PlacementTable
impl !RefUnwindSafe for PlacementTable
impl !UnwindSafe for PlacementTable
impl Send for PlacementTable
impl Sync for PlacementTable
impl Unpin for PlacementTable
impl UnsafeUnpin for PlacementTable
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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