pub struct Worker { /* private fields */ }Expand description
A worker that can poll for and respond to workflow tasks by using WorkflowFunctions, and activity tasks by using ActivityFunctions
Implementations§
Source§impl Worker
impl Worker
Sourcepub fn new_from_core(
worker: Arc<dyn CoreWorker>,
task_queue: impl Into<String>,
) -> Self
pub fn new_from_core( worker: Arc<dyn CoreWorker>, task_queue: impl Into<String>, ) -> Self
Create a new Rust SDK worker from a core worker
Sourcepub fn task_queue(&self) -> &str
pub fn task_queue(&self) -> &str
Returns the task queue name this worker polls on
Sourcepub fn shutdown_handle(&self) -> impl Fn() + use<>
pub fn shutdown_handle(&self) -> impl Fn() + use<>
Return a handle that can be used to initiate shutdown. TODO: Doc better after shutdown changes
Sourcepub fn register_wf(
&mut self,
workflow_type: impl Into<String>,
wf_function: impl Into<WorkflowFunction>,
)
pub fn register_wf( &mut self, workflow_type: impl Into<String>, wf_function: impl Into<WorkflowFunction>, )
Register a Workflow function to invoke when the Worker is asked to run a workflow of
workflow_type
Sourcepub fn register_activity<A, R, O>(
&mut self,
activity_type: impl Into<String>,
act_function: impl IntoActivityFunc<A, R, O>,
)
pub fn register_activity<A, R, O>( &mut self, activity_type: impl Into<String>, act_function: impl IntoActivityFunc<A, R, O>, )
Register an Activity function to invoke when the Worker is asked to run an activity of
activity_type
Sourcepub fn insert_app_data<T: Send + Sync + 'static>(&mut self, data: T)
pub fn insert_app_data<T: Send + Sync + 'static>(&mut self, data: T)
Insert Custom App Context for Workflows and Activities
Sourcepub async fn run(&mut self) -> Result<(), Error>
pub async fn run(&mut self) -> Result<(), Error>
Runs the worker. Eventually resolves after the worker has been explicitly shut down, or may return early with an error in the event of some unresolvable problem.
Sourcepub fn set_worker_interceptor(
&mut self,
interceptor: impl WorkerInterceptor + 'static,
)
pub fn set_worker_interceptor( &mut self, interceptor: impl WorkerInterceptor + 'static, )
Set a WorkerInterceptor
Sourcepub fn with_new_core_worker(&mut self, new_core_worker: Arc<dyn CoreWorker>)
pub fn with_new_core_worker(&mut self, new_core_worker: Arc<dyn CoreWorker>)
Turns this rust worker into a new worker with all the same workflows and activities registered, but with a new underlying core worker. Can be used to swap the worker for a replay worker, change task queues, etc.
Sourcepub fn cached_workflows(&self) -> usize
pub fn cached_workflows(&self) -> usize
Returns number of currently cached workflows as understood by the SDK. Importantly, this is not the same as understood by core, though they should always be in sync.
Auto Trait Implementations§
impl !Freeze for Worker
impl !RefUnwindSafe for Worker
impl !Send for Worker
impl !Sync for Worker
impl Unpin for Worker
impl !UnwindSafe for Worker
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request