pub struct Worker<I, O>{ /* private fields */ }
Expand description
Represents a running worker process.
Implementations§
source§impl<I, O> Worker<I, O>
impl<I, O> Worker<I, O>
sourcepub async fn start(worker_name: impl Into<Txt>) -> Result<Worker<I, O>, Error>
pub async fn start(worker_name: impl Into<Txt>) -> Result<Worker<I, O>, Error>
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<Worker<I, O>, Error>
pub async fn start_with( worker_name: impl Into<Txt>, env_vars: &[(&str, &str)], args: &[&str], ) -> Result<Worker<I, O>, Error>
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<Worker<I, O>, Error>
pub async fn start_other( worker_name: impl Into<Txt>, worker_exe: impl Into<PathBuf>, env_vars: &[(&str, &str)], args: &[&str], ) -> Result<Worker<I, O>, Error>
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<Worker<I, O>, Error>
pub async fn start_duct( worker_name: impl Into<Txt>, worker: Expression, ) -> Result<Worker<I, O>, Error>
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 async fn shutdown(self) -> Result<(), Error>
pub async fn shutdown(self) -> Result<(), Error>
Awaits current tasks and kills the worker process.
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§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