pub struct Worker<I: IpcValue, O: IpcValue> { /* private fields */ }
Expand description
Represents a running worker process.
Implementations§
source§impl<I: IpcValue, O: IpcValue> Worker<I, O>
impl<I: IpcValue, O: IpcValue> Worker<I, O>
sourcepub async fn start(worker_name: impl Into<Txt>) -> Result<Self>
pub async fn start(worker_name: impl Into<Txt>) -> Result<Self>
Start a worker process implemented in the current executable.
Note that the current process must call run_worker
at startup to actually work.
You can use zng_env::on_process_start!
to inject startup code.
sourcepub async fn start_with(
worker_name: impl Into<Txt>,
env_vars: &[(&str, &str)],
args: &[&str],
) -> Result<Self>
pub async fn start_with( worker_name: impl Into<Txt>, env_vars: &[(&str, &str)], args: &[&str], ) -> Result<Self>
Start a worker process implemented in the current executable with custom env vars and args.
sourcepub async fn start_other(
worker_name: impl Into<Txt>,
worker_exe: impl Into<PathBuf>,
env_vars: &[(&str, &str)],
args: &[&str],
) -> Result<Self>
pub async fn start_other( worker_name: impl Into<Txt>, worker_exe: impl Into<PathBuf>, env_vars: &[(&str, &str)], args: &[&str], ) -> Result<Self>
Start a worker process implemented in another executable with custom env vars and args.
sourcepub async fn start_duct(
worker_name: impl Into<Txt>,
worker: Expression,
) -> Result<Self>
pub async fn start_duct( worker_name: impl Into<Txt>, worker: Expression, ) -> Result<Self>
Start a worker process from a custom configured duct
process.
Note that the worker executable must call run_worker
at startup to actually work.
You can use zng_env::on_process_start!
to inject startup code.
sourcepub fn run(
&mut self,
input: I,
) -> impl Future<Output = Result<O, RunError>> + Send + 'static
pub fn run( &mut self, input: I, ) -> impl Future<Output = Result<O, RunError>> + Send + 'static
Run a task in a free worker thread.
sourcepub fn crash_error(&mut self) -> Option<&WorkerCrashError>
pub fn crash_error(&mut self) -> Option<&WorkerCrashError>
Crash error.
The worker cannot be used if this is set, run requests will immediately disconnect.
Trait Implementations§
Auto Trait Implementations§
impl<I, O> !Freeze for Worker<I, O>
impl<I, O> !RefUnwindSafe for Worker<I, O>
impl<I, O> Send for Worker<I, O>
impl<I, O> !Sync for Worker<I, O>
impl<I, O> Unpin for Worker<I, O>where
I: Unpin,
impl<I, O> !UnwindSafe for Worker<I, O>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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