Skip to content

Behaviors

casty.Behavior dataclass

Minimal actor behavior primitive.

Exactly one of on_receive, on_setup, or signal is set.

on_receive = None class-attribute instance-attribute

on_setup = None class-attribute instance-attribute

signal = None class-attribute instance-attribute

receive(handler) staticmethod

setup(factory) staticmethod

same() staticmethod

stopped() staticmethod

unhandled() staticmethod

restart() staticmethod

__init__(*, on_receive=None, on_setup=None, signal=None)

casty.Behaviors

Factory for composing behaviors from the Behavior primitive.

receive(handler) staticmethod

setup(factory) staticmethod

same() staticmethod

ignore() staticmethod

stopped() staticmethod

unhandled() staticmethod

restart() staticmethod

with_lifecycle(behavior, *, pre_start=None, post_stop=None, pre_restart=None, post_restart=None) staticmethod

supervise(behavior, strategy) staticmethod

spy(behavior, observer, *, spy_children=False) staticmethod

event_sourced(*, entity_id, journal, initial_state, on_event, on_command, snapshot_policy=None, replica_refs=None, replication=None) staticmethod

persisted(events, then=None) staticmethod

sharded(entity_factory, *, num_shards=100, replication=None) staticmethod

singleton(factory) staticmethod

discoverable(behavior, *, key) staticmethod

broadcasted(behavior) staticmethod

casty.Signal

Bases: Enum

same = auto() class-attribute instance-attribute

stopped = auto() class-attribute instance-attribute

restart = auto() class-attribute instance-attribute

unhandled = auto() class-attribute instance-attribute

casty.BroadcastedBehavior dataclass

behavior instance-attribute

__init__(behavior)

casty.EventSourcedBehavior dataclass

entity_id instance-attribute

journal instance-attribute

initial_state instance-attribute

on_event instance-attribute

on_command instance-attribute

snapshot_policy = None class-attribute instance-attribute

replica_refs = () class-attribute instance-attribute

replication = None class-attribute instance-attribute

__init__(entity_id, journal, initial_state, on_event, on_command, snapshot_policy=None, replica_refs=(), replication=None)

casty.PersistedBehavior dataclass

events instance-attribute

then instance-attribute

__init__(events, then)

casty.SnapshotEvery dataclass

n_events instance-attribute

__init__(n_events)

casty.SnapshotPolicy = SnapshotEvery

casty.SpyEvent dataclass

actor_path instance-attribute

event instance-attribute

timestamp instance-attribute

__init__(actor_path, event, timestamp)

casty.ShardedBehavior dataclass

entity_factory instance-attribute

num_shards = 100 class-attribute instance-attribute

replication = None class-attribute instance-attribute

__init__(entity_factory, num_shards=100, replication=None)

casty.SingletonBehavior dataclass

factory instance-attribute

__init__(factory)