pub trait WorkerSession: Send {
// Required methods
fn handshake<'life0, 'life1, 'async_trait>(
&'life0 mut self,
config: &'life1 WorkerConfig,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn register<'life0, 'life1, 'async_trait>(
&'life0 mut self,
activity_types: Vec<String>,
available_handlers: &'life1 BTreeSet<String>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn receive_tasks(&mut self) -> WorkerTaskStream;
fn report_result<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
run_id: Option<RunId>,
result: Payload,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn report_failure<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
run_id: Option<RunId>,
failure: ActivityError,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send_heartbeat<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
progress: Option<Payload>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn heartbeat_window(&self) -> Option<Duration> { ... }
}Expand description
Transport abstraction for the AW-owned worker protocol.
The current aion-proto worker endpoint is WorkerProtocol::StreamWorker,
a single bidirectional gRPC stream. These methods intentionally present the
worker conversation as handshake/register/receive/report/heartbeat phases so
execution machinery can be tested against fakes and never touches generated
stubs directly. If AW changes the wire shape, this trait adapts in this module.
Required Methods§
Sourcefn handshake<'life0, 'life1, 'async_trait>(
&'life0 mut self,
config: &'life1 WorkerConfig,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handshake<'life0, 'life1, 'async_trait>(
&'life0 mut self,
config: &'life1 WorkerConfig,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Performs the worker handshake for the configured namespace, task queue, and identity.
Maps to transport/channel establishment for AW’s StreamWorker RPC. The
wire carries the genuine namespace (correctness boundary) and
task_queue (pool selector) as disjoint registration fields; it has no
identity field, so identity is retained at this SDK boundary until the
wire adds a corresponding shape.
Sourcefn register<'life0, 'life1, 'async_trait>(
&'life0 mut self,
activity_types: Vec<String>,
available_handlers: &'life1 BTreeSet<String>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register<'life0, 'life1, 'async_trait>(
&'life0 mut self,
activity_types: Vec<String>,
available_handlers: &'life1 BTreeSet<String>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Registers activity-type names implemented by this worker.
Maps to opening AW’s StreamWorker RPC with RegisterWorker queued as
the mandatory first frame and then awaiting the server’s RegisterAck
— the guaranteed first frame on the response stream. Registration
succeeds only when the ack arrives; a denial fails the RPC with a gRPC
error status (PermissionDenied / Unauthenticated), and an ack that
does not arrive within the reconnect policy’s max_backoff is a
retryable registration failure. The caller supplies
available_handlers so registration can be rejected before serving if
any requested name lacks a handler.
Sourcefn receive_tasks(&mut self) -> WorkerTaskStream
fn receive_tasks(&mut self) -> WorkerTaskStream
Opens the receive side of AW’s StreamWorker RPC and yields pushed tasks.
Sourcefn report_result<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
run_id: Option<RunId>,
result: Payload,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn report_result<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
run_id: Option<RunId>,
result: Payload,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reports successful activity output via WorkerToServer.result.
Sourcefn report_failure<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
run_id: Option<RunId>,
failure: ActivityError,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn report_failure<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
run_id: Option<RunId>,
failure: ActivityError,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reports explicit activity failure via WorkerToServer.result.
Sourcefn send_heartbeat<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
progress: Option<Payload>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_heartbeat<'life0, 'async_trait>(
&'life0 mut self,
workflow_id: WorkflowId,
activity_id: ActivityId,
progress: Option<Payload>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends cooperative progress via WorkerToServer.heartbeat.
Provided Methods§
Sourcefn heartbeat_window(&self) -> Option<Duration>
fn heartbeat_window(&self) -> Option<Duration>
Server-assigned liveness window from the RegisterAck, once registered.
The serve loop derives its AUTOMATIC liveness-heartbeat cadence from
this window (see serve_activity_tasks_until): the server’s heartbeat
sweeper expires any worker whose in-flight task goes longer than the
window without a heartbeat, so the runtime — not each handler — must
keep every in-flight activity beating. None (the default, and the
value for fake/unregistered sessions) disables the automatic pump.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".