class documentation

Resonate client.

Class Method local Create a Resonate client with local configuration.
Class Method remote Create a Resonate client with remote configuration.
Method __init__ Create a Resonate client.
Method begin_rpc Run a function with Resonate remotely.
Method begin_run Run a function with Resonate.
Method get Subscribe to an execution.
Method options Configure options for the function.
Method register Register function with Resonate.
Method rpc Run a function with Resonate remotely and wait for the result.
Method run Run a function with Resonate and wait for the result.
Method set_dependency Store a named dependency for use with Context.
Method start Explicitly start Resonate threads.
Method stop Stop resonate.
Property promises Promises low level client.
Property schedules Schedules low level client.
Instance Variable _bridge Undocumented
Instance Variable _dependencies Undocumented
Instance Variable _group Undocumented
Instance Variable _log_level Undocumented
Instance Variable _message_source Undocumented
Instance Variable _opts Undocumented
Instance Variable _pid Undocumented
Instance Variable _registry Undocumented
Instance Variable _started Undocumented
Instance Variable _store Undocumented
Instance Variable _ttl Undocumented
Instance Variable _workers Undocumented
@classmethod
def local(cls, dependencies: Dependencies | None = None, group: str = 'default', log_level: int | Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] = logging.INFO, pid: str | None = None, registry: Registry | None = None, ttl: int = 10, workers: int | None = None) -> Resonate:

Create a Resonate client with local configuration.

This configuration stores all state in memory, with no external persistence or network I/O. The in memory store implements the same API as the remote store, making it perfect for rapid development, local testing, and experimentation.

@classmethod
def remote(cls, auth: tuple[str, str] | None = None, dependencies: Dependencies | None = None, group: str = 'default', host: str | None = None, log_level: int | Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] = logging.INFO, message_source_port: str | None = None, pid: str | None = None, registry: Registry | None = None, store_port: str | None = None, ttl: int = 10, workers: int | None = None) -> Resonate:

Create a Resonate client with remote configuration.

This configuration persists all state to a remote store, enabling full durability, coordination, and recovery protocols across processes.

The remote store implementation is ideal for production workloads, fault-tolerant scheduling, and distributed execution.

def __init__(self, *, dependencies: Dependencies | None = None, group: str = 'default', log_level: int | Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] = logging.NOTSET, message_source: MessageSource | None = None, pid: str | None = None, registry: Registry | None = None, store: Store | None = None, ttl: int = 10, workers: int | None = None):

Create a Resonate client.

@overload
def begin_rpc(self, id: str, func: Callable[Concatenate[Context, P], Generator[Any, Any, R] | R], *args: P.args, **kwargs: P.kwargs) -> Handle[R]:
@overload
def begin_rpc(self, id: str, func: str, *args: Any, **kwargs: Any) -> Handle[Any]:

Run a function with Resonate remotely.

If a durable promise with the same id already exists, the method will subscribe to its result or return the value immediately if the promise has been completed.

Resonate will prevent duplicate executions for the same id.

  • Function must be registered
  • Function args and kwargs must be serializable
@overload
def begin_run(self, id: str, func: Callable[Concatenate[Context, P], Generator[Any, Any, R] | R], *args: P.args, **kwargs: P.kwargs) -> Handle[R]:
@overload
def begin_run(self, id: str, func: str, *args: Any, **kwargs: Any) -> Handle[Any]:

Run a function with Resonate.

If a durable promise with the same id already exists, the method will subscribe to its result or return the value immediately if the promise has been completed.

Resonate will prevent duplicate executions for the same id.

  • Function must be registered
  • Function args and kwargs must be serializable
def get(self, id: str) -> Handle[Any]:

Subscribe to an execution.

A durable promise with the same id must exist. Returns immediately if the promise has been completed.

def options(self, *, encoder: Encoder[Any, str | None] | None = None, idempotency_key: str | Callable[[str], str] | None = None, retry_policy: RetryPolicy | Callable[[Callable], RetryPolicy] | None = None, tags: dict[str, str] | None = None, target: str | None = None, timeout: float | None = None, version: int | None = None) -> Resonate:

Configure options for the function.

  • encoder: Configure your own data encoder.
  • idempotency_key: Define the idempotency key invocation or a function that
    receives the promise id and creates an idempotency key.
  • retry_policy: Define the retry policy: exponential | constant | linear | never
  • tags: Add custom tags to the durable promise representing the invocation.
  • target: Target to distribute the invocation.
  • timeout: Number of seconds before the invocation timesout.
  • version: Version of the function to invoke.
@overload
def register(self, func: Callable[Concatenate[Context, P], R], /, *, name: str | None = None, version: int = 1) -> Function[P, R]:
@overload
def register(self, *, name: str | None = None, version: int = 1) -> Callable[[Callable[Concatenate[Context, P], R]], Function[P, R]]:

Register function with Resonate.

This method makes the provided function available for top level execution under the specified name and version.

It can be used directly by passing the target function, or as a decorator.

When used without arguments, the function itself is decorated and registered with the default name (derived from the function) and version. Providing a name or version allows explicit control over the function identifier and its versioning for subsequent invocations.

@overload
def rpc(self, id: str, func: Callable[Concatenate[Context, P], Generator[Any, Any, R] | R], *args: P.args, **kwargs: P.kwargs) -> R:
@overload
def rpc(self, id: str, func: str, *args: Any, **kwargs: Any) -> Any:

Run a function with Resonate remotely and wait for the result.

If a durable promise with the same id already exists, the method will subscribe to its result or return the value immediately if the promise has been completed.

Resonate will prevent duplicate executions for the same id.

  • Function must be registered
  • Function args and kwargs must be serializable
  • This is a blocking operation
@overload
def run(self, id: str, func: Callable[Concatenate[Context, P], Generator[Any, Any, R] | R], *args: P.args, **kwargs: P.kwargs) -> R:
@overload
def run(self, id: str, func: str, *args: Any, **kwargs: Any) -> Any:

Run a function with Resonate and wait for the result.

If a durable promise with the same id already exists, the method will subscribe to its result or return the value immediately if the promise has been completed.

Resonate will prevent duplicate executions for the same id.

  • Function must be registered
  • Function args and kwargs must be serializable
  • This is a blocking operation
def set_dependency(self, name: str, obj: Any):

Store a named dependency for use with Context.

The dependency is made available to all functions via their execution Context.

def start(self):

Explicitly start Resonate threads.

This happens automatically when calling .run() or .rpc(), but is generally recommended for all workers that have functions registered with Resonate.

def stop(self):

Stop resonate.

@property
promises: PromiseStore =

Promises low level client.

@property
schedules: ScheduleStore =

Schedules low level client.

_bridge =

Undocumented

_dependencies =

Undocumented

_group =

Undocumented

_log_level =

Undocumented

_message_source =

Undocumented

_opts =

Undocumented

_pid =

Undocumented

_registry =

Undocumented

_started: bool =

Undocumented

_store =

Undocumented

_ttl =

Undocumented

_workers =

Undocumented