Skip to main content

ControllerHandle

Struct ControllerHandle 

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

Non-blocking handle to a running Controller. Returned by spawn_controller; used by the scriptable builtins to drive the distributed compute fabric from .stk code.

Implementations§

Source§

impl ControllerHandle

Source

pub fn listen_addr(&self) -> SocketAddr

Returns the address the listener is actually bound to (port may have been auto-assigned if 0 was passed in).

Source

pub fn agent_count(&self) -> usize

Current count of connected agents.

Source

pub fn muster(&self) -> Vec<u64>

Return session IDs of all currently connected agents, in numerically sorted order (deterministic for tests and scripts).

Source

pub fn welcome(&self, target_count: usize, timeout: Duration) -> bool

Block until at least target_count agents are connected, or timeout elapses. Returns true if the count was reached. Polls every 50ms.

Source

pub fn scatter(&self, code: &str, agent_ids: &[u64]) -> Result<u64>

Fan EVAL out to agent_ids in parallel. Returns a petition_id used later with gather to collect results. Agents that don’t exist in the roster or whose write fails are silently dropped from the dispatched set, so a stale agent_id in agent_ids does NOT cause the whole scatter to fail.

Returns Err only if the EvalCommand fails to bincode-serialize (which should never happen for plain strings).

Source

pub fn gather( &self, petition_id: u64, timeout: Duration, ) -> Result<HashMap<u64, EvalResult>>

Block for results of petition_id up to timeout (per-agent read timeout, not total wall time). Returns a HashMap of session_id → EvalResult for every agent that replied with a valid EVAL_RESULT frame in time. Agents that timed out, errored, or disconnected are omitted from the map.

Stale frames in the per-agent socket buffer (e.g. METRICS left over from a prior FIRE) are silently skipped — same loop pattern as eval_all so manual REPL behaviour stays consistent with scripted.

Removes the divination from the pending table on return, so a second gather on the same petition_id is an error.

Source

pub fn chant(&self, code: &str, agent_ids: &[u64]) -> Result<u64>

Register an active chant — a prayer that fires at every current agent now AND at every new agent that joins later (via the accept_loopfire_chants_at path). Returns a chant_id used by amen_chant to stop the rescatter.

Fire-and-forget: chants don’t accumulate replies. Use for state distribution (bestow-like push to current + future workers).

Source

pub fn amen_chant(&self, chant_id: u64) -> bool

Stop an active chant. Late joiners after this call won’t receive it. Returns true if the chant was active and removed, false otherwise.

Source

pub fn set_quiet_accept(&self, quiet: bool)

Silence the accept_loop’s per-agent “[agent connected]” eprintln. Set to true before a bulk-spawn loop (congregation(N) / anoint(N)) to prevent the fork-thread/stdio RefCell race that loses 1-3 children at N>~50 on macOS Rust stdio. Set back to false after the spawn loop completes if you want the REPL UX back.

Source

pub fn set_cloistered(&self, token: Option<&str>)

Turn :cloistered mode on (with a single accepted token) or off (with an empty token). Cloistered accept_loop reads an AGENT_AUTH frame after HELLO and rejects agents that don’t present a valid token. Open mode bypasses the AUTH read entirely.

Source

pub fn excommunicate(&self, agent_ids: &[u64]) -> usize

Send SHUTDOWN to a specific subset of agents (the excommunicate verb). Each agent receives a SHUTDOWN frame and exits its loop; the agent’s TCP connection is dropped. Returns the count of agents that the frame was successfully written to (write failures from disconnected agents are silently swallowed — same convention as scatter).

Source

pub fn pilgrimage( &self, barrier_code: &str, agent_ids: &[u64], timeout: Duration, ) -> bool

Pilgrimage barrier — scatter barrier_code to all agent_ids and block until every agent that received the frame replies, OR timeout elapses. Returns true if every dispatched agent replied in time.

barrier_code is the prayer the agents execute at the barrier; for a pure rendezvous, pass "1" and the agent’s reply is the synchronization signal. For computational barriers, pass code that does the work and returns when done.

Source

pub fn shutdown(&self)

SHUTDOWN every agent, stop the accept loop, join the accept thread. Wakes the blocking listener.incoming() call by self-connecting to the bound address (the connection’s HELLO read will fail and the accept thread will exit its loop now that running is false).

Source

pub fn run_repl_blocking(&self)

Run the existing REPL on the calling thread, then clean shutdown. Used by run_controller for back-compat with the CLI subcommand.

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
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 Metadata = ()

The type for metadata in pointers and references to Self.
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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<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