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
impl LeanWorker
Sourcepub fn open_session<'worker>(
&'worker mut self,
config: &LeanWorkerSessionConfig,
cancellation: Option<&LeanWorkerCancellationToken>,
progress: Option<&dyn LeanWorkerProgressSink>,
) -> Result<LeanWorkerSession<'worker>, LeanWorkerError>
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
impl LeanWorker
Sourcepub fn spawn(config: &LeanWorkerConfig) -> Result<Self, LeanWorkerError>
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.
Sourcepub fn health(&mut self) -> Result<(), LeanWorkerError>
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.
Sourcepub fn load_fixture_capability(
&mut self,
fixture_root: impl AsRef<Path>,
) -> Result<(), LeanWorkerError>
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.
Sourcepub fn call_fixture_mul(
&mut self,
fixture_root: impl AsRef<Path>,
lhs: u64,
rhs: u64,
) -> Result<u64, LeanWorkerError>
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.
Sourcepub fn status(&mut self) -> Result<LeanWorkerStatus, LeanWorkerError>
pub fn status(&mut self) -> Result<LeanWorkerStatus, LeanWorkerError>
Return the current worker lifecycle status.
§Errors
Returns LeanWorkerError if checking the process status fails.
Sourcepub fn stats(&self) -> LeanWorkerStats
pub fn stats(&self) -> LeanWorkerStats
Return lifecycle counters for this supervisor.
Sourcepub fn runtime_metadata(&self) -> LeanWorkerRuntimeMetadata
pub fn runtime_metadata(&self) -> LeanWorkerRuntimeMetadata
Return protocol/runtime facts reported by the worker child.
Sourcepub fn rss_kib(&mut self) -> Option<u64>
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.
Sourcepub fn request_timeout(&self) -> Duration
pub fn request_timeout(&self) -> Duration
Return the timeout used for subsequent worker requests.
Sourcepub fn set_request_timeout(&mut self, timeout: Duration)
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.
Sourcepub fn cycle(&mut self) -> Result<(), LeanWorkerError>
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.
Sourcepub fn restart(&mut self) -> Result<(), LeanWorkerError>
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.
Sourcepub fn terminate(self) -> Result<LeanWorkerExit, LeanWorkerError>
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.