Skip to main content

Worker

Struct Worker 

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

Hosts registered Flow Step and RPC handlers over application WorkerService.

A Worker owns an internal Tokio runtime and is one-shot. Self::start first synchronizes Attribute indexes with Dex, then blocks the calling thread while serving gRPC. Call Self::stop from another thread to request graceful server shutdown.

§Examples

use dex_sdk::{BlobCache, BlobCacheConfig, Registry, Worker, WorkerOptions};
use std::sync::Arc;

let cache = Arc::new(BlobCache::open(BlobCacheConfig::new(
    "/tmp/dex-blobs", 64 * 1024 * 1024, 0,
)?)?);
let worker = Worker::try_new(Registry::new(), cache, WorkerOptions::new())?;
println!("advertise {}", worker.worker_target().address());
worker.start()?;

Implementations§

Source§

impl Worker

Source

pub fn new( registry: Registry, blob_cache: Arc<BlobCache>, options: WorkerOptions, ) -> Self

Creates a Worker or panics when options or runtime initialization are invalid.

§Panics

Panics for an invalid bind address, zero index-sync timeout, invalid Dex endpoint, or Tokio runtime creation failure. Prefer Self::try_new for recoverable startup.

Source

pub fn try_new( registry: Registry, blob_cache: Arc<BlobCache>, options: WorkerOptions, ) -> SdkResult<Self>

Creates a one-shot Worker without binding its listener.

§Errors

Returns SdkError::FlowDefinition for invalid Worker options or Service for runtime and endpoint initialization failures. The Dex connection is lazy.

Source

pub fn worker_target(&self) -> &WorkerTarget

Returns the resolved WorkerService target that Clients should advertise to Dex.

Source

pub fn start(&self) -> SdkResult<()>

Synchronizes Attribute indexes, serves WorkerService, and blocks until stopped or failed.

§Errors

Returns FlowDefinition if called more than once, or Service for index synchronization, timeout, bind, and server failures.

Source

pub fn stop(&self)

Requests shutdown of a running Worker and returns immediately.

Calling stop before or after start is safe; Self::start observes the shutdown signal.

Auto Trait Implementations§

§

impl !Freeze for Worker

§

impl !RefUnwindSafe for Worker

§

impl !UnwindSafe for Worker

§

impl Send for Worker

§

impl Sync for Worker

§

impl Unpin for Worker

§

impl UnsafeUnpin for Worker

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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 = !

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