pub struct ServerlessWorker { /* private fields */ }serverless only.Expand description
RunPod Serverless worker loop.
Implementations§
Source§impl ServerlessWorker
impl ServerlessWorker
Sourcepub fn new(config: WorkerConfig) -> Result<Self>
pub fn new(config: WorkerConfig) -> Result<Self>
Create a worker from explicit configuration.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a worker from RunPod Serverless environment variables.
Sourcepub async fn run<H, Fut>(&self, handler: H) -> Result<()>
pub async fn run<H, Fut>(&self, handler: H) -> Result<()>
Run the worker loop forever, with up to WorkerConfig::concurrency
jobs in flight at once.
Spawns concurrency independent copies of the poll/process loop
(concurrency defaults to 1, from RUNPOD_WORKER_CONCURRENCY via
WorkerConfig::from_env) — each copy is still internally
sequential (take_job → await handler to completion →
post_result → repeat), but running concurrency of them side by
side lets that many jobs actually overlap, which matters for any
handler backed by a worker pool wider than one (e.g. multiple GPU
inference slots). A single heartbeat task is still shared across
all of them and reports every concurrently active job id (see
start_heartbeat/active_jobs).
handler needs Send + Sync + 'static (and Fut: Send + 'static)
so it can be shared across the spawned tasks — virtually always
true already for realistic async worker handlers running on a
multi-threaded Tokio runtime.
Trait Implementations§
Source§impl Clone for ServerlessWorker
impl Clone for ServerlessWorker
Source§fn clone(&self) -> ServerlessWorker
fn clone(&self) -> ServerlessWorker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more