Skip to main content

WorkerSession

Trait WorkerSession 

Source
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,
        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,
        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;
}
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§

Source

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 task queue and identity.

Maps to transport/channel establishment for AW’s StreamWorker RPC. AW currently names the task-queue scope namespace and has no identity field, so identity is retained at this SDK boundary until the wire adds a corresponding shape.

Source

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.

Source

fn receive_tasks(&mut self) -> WorkerTaskStream

Opens the receive side of AW’s StreamWorker RPC and yields pushed tasks.

Source

fn report_result<'life0, 'async_trait>( &'life0 mut self, workflow_id: WorkflowId, activity_id: ActivityId, 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.

Source

fn report_failure<'life0, 'async_trait>( &'life0 mut self, workflow_id: WorkflowId, activity_id: ActivityId, 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.

Source

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§