pub struct Worker {
pub id: String,
pub links: Vec<ResourceRef>,
pub triggers: Vec<WorkerTrigger>,
pub public_endpoints: Vec<WorkerPublicEndpoint>,
pub permissions: String,
pub code: WorkerCode,
pub memory_mb: u32,
pub timeout_seconds: u32,
pub environment: HashMap<String, String>,
pub commands_enabled: bool,
pub concurrency_limit: Option<u32>,
pub readiness_probe: Option<ReadinessProbe>,
}Expand description
Represents a serverless worker that executes code in response to triggers or direct invocations. Workers are the primary compute resource in serverless applications, designed to be stateless and ephemeral.
Fields§
§id: StringIdentifier for the worker. Must contain only alphanumeric characters, hyphens, and underscores ([A-Za-z0-9-_]). Maximum 64 characters.
links: Vec<ResourceRef>List of resource references this worker depends on.
triggers: Vec<WorkerTrigger>List of triggers that define what events automatically invoke this worker. If empty, the worker is only invokable directly via HTTP calls or platform-specific invocation APIs. When configured, the worker will be automatically invoked when any of the specified trigger conditions are met.
public_endpoints: Vec<WorkerPublicEndpoint>Public endpoints exposed by this worker.
permissions: StringPermission profile name that defines the permissions granted to this worker. This references a profile defined in the stack’s permission definitions.
code: WorkerCodeCode for the worker, either a pre-built image or source code to be built.
memory_mb: u32Memory allocated to the worker in megabytes (MB). Default: 256
Platform-specific constraints:
- AWS Lambda: 128–10240 MB in 1 MB increments
- GCP Cloud Run: 128–32768 MB
- Azure Container Apps: fixed CPU/memory pairs — 512, 1024, 1536, 2048, 2560, 3072, 3584, 4096 MB. Values below 512 are automatically rounded up at deploy time.
timeout_seconds: u32Maximum execution time for the worker in seconds. Constraints: 1‑3600 seconds (platform-specific limits may apply) Default: 30
environment: HashMap<String, String>Key-value pairs to set as environment variables for the worker.
commands_enabled: boolWhether the worker can receive remote commands via the Commands protocol. When enabled, the runtime polls the manager for pending commands and executes registered handlers.
concurrency_limit: Option<u32>Maximum number of concurrent executions allowed for the worker. None means platform default applies.
readiness_probe: Option<ReadinessProbe>Optional readiness probe configuration. Only applicable for workers with Public ingress. When configured, the probe will be executed after provisioning/update to verify the worker is ready.
Implementations§
Source§impl Worker
impl Worker
Sourcepub fn new(id: String) -> WorkerBuilder
pub fn new(id: String) -> WorkerBuilder
Create an instance of Worker using the builder syntax
Source§impl Worker
impl Worker
Sourcepub const RESOURCE_TYPE: ResourceType
pub const RESOURCE_TYPE: ResourceType
The resource type identifier for Workers
Sourcepub fn get_permissions(&self) -> &str
pub fn get_permissions(&self) -> &str
Returns the permission profile name for this worker.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Worker
impl<'de> Deserialize<'de> for Worker
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Worker
Source§impl ResourceDefinition for Worker
impl ResourceDefinition for Worker
Source§fn get_resource_type(&self) -> ResourceType
fn get_resource_type(&self) -> ResourceType
Source§fn get_dependencies(&self) -> Vec<ResourceRef>
fn get_dependencies(&self) -> Vec<ResourceRef>
Source§fn get_permissions(&self) -> Option<&str>
fn get_permissions(&self) -> Option<&str>
Source§fn validate_update(&self, new_config: &dyn ResourceDefinition) -> Result<()>
fn validate_update(&self, new_config: &dyn ResourceDefinition) -> Result<()>
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn box_clone(&self) -> Box<dyn ResourceDefinition>
fn box_clone(&self) -> Box<dyn ResourceDefinition>
Source§fn resource_eq(&self, other: &dyn ResourceDefinition) -> bool
fn resource_eq(&self, other: &dyn ResourceDefinition) -> bool
Source§fn to_json_value(&self) -> Result<Value>
fn to_json_value(&self) -> Result<Value>
impl StructuralPartialEq for Worker
Auto Trait Implementations§
impl Freeze for Worker
impl RefUnwindSafe for Worker
impl Send for Worker
impl Sync for Worker
impl Unpin for Worker
impl UnsafeUnpin for Worker
impl UnwindSafe for Worker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.