pub trait Worker: Binding {
// Required methods
fn invoke<'life0, 'async_trait>(
&'life0 self,
request: WorkerInvokeRequest,
) -> Pin<Box<dyn Future<Output = Result<WorkerInvokeResponse, AlienError<ErrorData>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_worker_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, AlienError<ErrorData>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn as_any(&self) -> &(dyn Any + 'static);
}Expand description
A trait for worker bindings that enable direct worker-to-worker calls.
Required Methods§
Sourcefn invoke<'life0, 'async_trait>(
&'life0 self,
request: WorkerInvokeRequest,
) -> Pin<Box<dyn Future<Output = Result<WorkerInvokeResponse, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
request: WorkerInvokeRequest,
) -> Pin<Box<dyn Future<Output = Result<WorkerInvokeResponse, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Invoke a worker with HTTP request data.
This enables direct, low-latency worker-to-worker communication within the same cloud environment, bypassing Commands for internal calls.
Platform implementations:
- AWS: Uses InvokeWorker API directly
- GCP: Calls private service URL directly
- Azure: Calls private container app URL directly
- Kubernetes: HTTP call to internal service
Sourcefn get_worker_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_worker_url<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Get the public URL of the worker, if available.
Returns the worker’s public URL if it exists and is accessible. This is useful for exposing public endpoints or getting URLs for external integration.
Platform implementations:
- AWS: Uses GetWorkerUrlConfig API or returns URL from binding
- GCP: Returns Cloud Run service URL or calls get_service API
- Azure: Returns Container App URL or calls get_container_app API
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".