Skip to main content

WorkloadHostService

Struct WorkloadHostService 

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

A node’s workload-host.

Implementations§

Source§

impl WorkloadHostService

Source

pub fn set_licence_gate(&self, gate: Arc<dyn CognitumRunGate>) -> bool

Use gate for Cognitum-origin cogs (first call wins).

Source

pub fn licence_gate(&self) -> Option<&Arc<dyn CognitumRunGate>>

The licence run gate in use, if one was set.

Source§

impl WorkloadHostService

Source

pub fn set_node_admin(&self, hook: Arc<dyn NodeAdmin>) -> bool

Install the node-admin hook (first call wins).

Source§

impl WorkloadHostService

Source

pub async fn enforce_revocations( &self, list: &RevocationList, ) -> Vec<ForcedTeardown>

Stop and unload every hosted instance that list now revokes. Idempotent: instances already gone are not touched. Instances that cannot be torn down stay held and are reported with unloaded: false, so the next call retries them.

The instance map is locked only to pick the targets and to forget the ones that went; the teardowns (each up to the stop grace) run outside it, so a revocation sweep never holds up status, stop or place on this node.

Source§

impl WorkloadHostService

Source

pub fn new( key: SigningKey, exchange: Arc<ArtifactExchange>, anchors: TrustAnchors, gate: Arc<dyn GateBackend>, ) -> Self

Host for the node owning key. Serves nobody until controllers are added, and loads nothing until a route adapter is added.

Source

pub fn with_kinds(self, kinds: KindRegistry) -> Self

Accept these workload kinds for a package fetched from a peer. The default is KindRegistry::builtin; a node that places a registered non-cog kind across nodes must pass the same registry as its control plane, or the fetch refuses the kind.

Source

pub fn set_revocations(&self, list: Arc<RevocationList>) -> bool

The revocation list this node enforces (first call wins). With it a place that races a revocation is caught and torn down, and Self::enforce_revocations callers share one source of truth.

Source

pub fn revocations(&self) -> Option<&Arc<RevocationList>>

The list set by Self::set_revocations, if any.

Source

pub fn with_ingest(self, hooks: IngestHooks) -> Self

Wire the ingest bridge: placed cogs get a per-instance token, bound to the placing project and revoked at stop and unload.

Source

pub fn ingest(&self) -> Option<&IngestHooks>

The ingest wiring, if any.

Source

pub fn with_refusal_budget(self, b: RefusalBudget) -> Self

Replace the bound on chained refusals of unverified requests.

Source

pub fn with_route(self, route: &str, host: Arc<WorkloadHost>) -> Self

Adapter (under governance) for one route kind (native, …).

Source

pub fn with_controllers(self, c: impl ControllerPolicy + 'static) -> Self

Who may send requests.

Source

pub fn with_chain(self, cm: Arc<ChainManager>) -> Self

Chain for placement and refusal records.

Source

pub fn with_address(self, addr: impl Into<String>) -> Self

Mesh address advertised for this service.

Source

pub fn set_facts(&self, facts: SignedNodeFacts)

Replace the signed facts describe returns.

Source

pub fn with_facts_source(self, source: FactsSource) -> Self

Read the signed facts from source on every describe (falling back to Self::set_facts when it has none).

Source

pub fn node_id(&self) -> &str

This node’s id.

Source

pub fn advertisement(&self) -> ServiceAdvertisement

The workload-host advertisement (ADR-099 section 7).

Source

pub async fn handle( &self, header_method: &str, signed: &SignedCtl, fetch: Option<&mut PeerSet>, ) -> SignedCtl

Handle one signed request (fetch is the connection back to the controller, used to fetch the payload before loading).

Source

pub async fn handle_checked( &self, header_method: &str, signed: &SignedCtl, fetch: Option<&mut PeerSet>, ) -> (SignedCtl, bool)

Self::handle, also saying whether the request was authenticated (a session drops a peer after an unauthenticated request).

Source§

impl WorkloadHostService

Source

pub fn with_kind_registry(self, kinds: KindRegistry) -> Self

Use these kinds’ health definitions (default: the built-in kinds).

Source

pub fn with_lease(self, lease: Duration) -> Self

Opt in to the node-side lease: continuous instances stop once no controller other than this node itself has been heard from for lease, and only for instances another node placed. It must be longer than the controller’s tick (a lease shorter than a few ticks would stop work for ordinary jitter) and, to stop the old copy before a replacement starts, at most the controller’s dead_after. Set it at or below the controller’s dead_after, so the copy on a partitioned node stops before the controller starts a replacement. Off by default.

Source

pub fn with_restart_policy(self, p: RestartPolicy) -> Self

Replace the restart bounds.

Source

pub async fn lifecycle_of(&self, instance_id: &str) -> Option<LifecycleState>

Lifecycle state of a hosted instance.

Source

pub async fn supervise(&self, now_ms: u64) -> Vec<Supervised>

Run the health heartbeat and the bounded restarts once, at now_ms. Returns what changed. Instances are polled outside the instance map’s lock, so a slow adapter never holds up status or place.

Source

pub fn spawn_supervisor(self: &Arc<Self>, period: Duration) -> JoinHandle<()> ⓘ

Run Self::supervise every period for as long as the runtime lives.

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