Writing handlers
Handlers receive a Restate context object (ctx) and a single, optional input:
The input and output can be any JSON-serializable type. For other types, consult the serialization documentation of your SDK.
Context types
The context type you use depends on your service type:Context- Basic Services (stateless handlers)ObjectContext- Virtual Objects (exclusive handlers with state access)ObjectSharedContext- Virtual Objects (concurrent read-only handlers)WorkflowContext- Workflows (main run handler)WorkflowSharedContext- Workflows (signal/query handlers)
Handler behavior
Virtual Objects and Workflows support two handler types: Exclusive handlers (ObjectContext, WorkflowContext) can read and write state but only one runs at a time per key to prevent conflicts.
Shared handlers (ObjectSharedContext, WorkflowSharedContext) can only read state but run concurrently without blocking—useful for querying status during long-running operations.