Skip to main content

LeanWorker

Struct LeanWorker 

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

Supervisor for one lean-rs-worker child process.

Dropping a live supervisor attempts to terminate the child and then waits for it. Drop never panics; explicit terminate is preferred when callers need the exit status.

Implementations§

Source§

impl LeanWorker

Source

pub fn open_session<'worker>( &'worker mut self, config: &LeanWorkerSessionConfig, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerSession<'worker>, LeanWorkerError>

Open a host session inside the worker child.

§Errors

Returns LeanWorkerError if the worker is dead, the child cannot open the Lake project/capability/imports, cancellation is already requested, or protocol communication fails.

Source§

impl LeanWorker

Source

pub fn spawn(config: &LeanWorkerConfig) -> Result<Self, LeanWorkerError>

Spawn a worker child and wait for its protocol handshake.

§Errors

Returns LeanWorkerError if the child cannot be spawned, child setup fails, the child exits before handshaking, or the startup timeout expires.

Source

pub fn health(&mut self) -> Result<(), LeanWorkerError>

Check whether the worker responds to requests.

§Errors

Returns LeanWorkerError if the worker is dead, the protocol fails, or the child returns a typed worker error.

Source

pub fn load_fixture_capability( &mut self, fixture_root: impl AsRef<Path>, ) -> Result<(), LeanWorkerError>

Load the in-tree fixture capability in the worker child.

This is a fixture-only entry point used to exercise the supervisor path in tests. The supported public path is open_session, which returns the host-session adapter instead of expanding this fixture surface.

§Errors

Returns LeanWorkerError if the worker is dead, fixture loading fails, or protocol communication fails.

Source

pub fn call_fixture_mul( &mut self, fixture_root: impl AsRef<Path>, lhs: u64, rhs: u64, ) -> Result<u64, LeanWorkerError>

Call the prompt fixture multiplication export in the worker child.

§Errors

Returns LeanWorkerError if the worker is dead, the export fails, or protocol communication fails.

Source

pub fn status(&mut self) -> Result<LeanWorkerStatus, LeanWorkerError>

Return the current worker lifecycle status.

§Errors

Returns LeanWorkerError if checking the process status fails.

Source

pub fn stats(&self) -> LeanWorkerStats

Return lifecycle counters for this supervisor.

Source

pub fn runtime_metadata(&self) -> LeanWorkerRuntimeMetadata

Return protocol/runtime facts reported by the worker child.

Source

pub fn rss_kib(&mut self) -> Option<u64>

Measure the current child RSS in KiB when supported by the platform.

This is an observability hook for restart policy and memory-cycling workloads. A None result means the platform did not provide a usable sample; it is not a worker failure.

Source

pub fn request_timeout(&self) -> Duration

Return the timeout used for subsequent worker requests.

Source

pub fn set_request_timeout(&mut self, timeout: Duration)

Change the timeout for subsequent worker requests.

This changes supervisor policy only. The supervisor still owns the deadline, child kill, replacement, and restart accounting.

Source

pub fn cycle(&mut self) -> Result<(), LeanWorkerError>

Explicitly cycle the worker process.

This is the manual memory-reset operation. It terminates the current child, starts a replacement with the original configuration, and records LeanWorkerRestartReason::Explicit.

§Errors

Returns LeanWorkerError if the existing child cannot be waited on or the replacement child cannot be spawned and handshaken.

Source

pub fn restart(&mut self) -> Result<(), LeanWorkerError>

Restart this worker using its original configuration.

This is an explicit lifecycle operation. Prompt 58 adds policy-driven restarts for memory cycling; this method only gives callers a direct reset point.

§Errors

Returns LeanWorkerError if the existing child cannot be waited on or the replacement child cannot be spawned and handshaken.

Source

pub fn terminate(self) -> Result<LeanWorkerExit, LeanWorkerError>

Ask the child to terminate cleanly and wait for it.

§Errors

Returns LeanWorkerError if the worker is already dead, the protocol fails, or waiting for the child process fails.

Trait Implementations§

Source§

impl Debug for LeanWorker

Source§

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

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

impl Drop for LeanWorker

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<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> 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 = 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