Struct Worker

Source
pub struct Worker<H, F>
where H: Fn(UnixStream, String) -> F, F: Future<Output = Result<()>>,
{ /* private fields */ }
Expand description

Worker process handler.

Implementations§

Source§

impl<H, F> Worker<H, F>
where H: Fn(UnixStream, String) -> F, F: Future<Output = Result<()>>,

Source

pub fn new() -> Self

Create a new worker.

Source

pub fn relaxed(self, flag: bool) -> Self

Set the relaxed flag.

When a worker is relaxed it will start with or without a supervisor.

The default is false so workers expect to be run in the context of a supervisor and it is an error if no worker id is available in the environment.

When this flag is enabled and the required environment variables do not exist the worker does not attempt to connect to a supervisor.

Use this mode of operation when a worker process can be run standalone or as a worker for a supervisor process.

Source

pub fn client(self, handler: H) -> Self

Set a client connection handler.

The handler function receives the socket stream and opaque worker identifier and can communicate with the supervisor using the socket stream.

Source

pub async fn run(&self) -> Result<()>

Start this worker running.

Auto Trait Implementations§

§

impl<H, F> Freeze for Worker<H, F>
where H: Freeze,

§

impl<H, F> RefUnwindSafe for Worker<H, F>
where H: RefUnwindSafe,

§

impl<H, F> Send for Worker<H, F>
where H: Send,

§

impl<H, F> Sync for Worker<H, F>
where H: Sync,

§

impl<H, F> Unpin for Worker<H, F>
where H: Unpin,

§

impl<H, F> UnwindSafe for Worker<H, F>
where H: UnwindSafe,

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