Skip to content

Receptionist

casty.ServiceKey dataclass

Typed key identifying a service in the cluster registry.

Parameters:

Name Type Description Default
name str

Human-readable service name (e.g. "payment-service").

required

Examples:

>>> key: ServiceKey[int] = ServiceKey("counter")
>>> key.name
'counter'

name instance-attribute

__init__(name)

casty.ServiceInstance dataclass

A single instance of a service in the cluster.

Parameters:

Name Type Description Default
ref ActorRef[M]

Reference to the actor providing the service.

required
node NodeAddress

Node where the actor lives.

required

Examples:

>>> instance = ServiceInstance(ref=some_ref, node=NodeAddress("127.0.0.1", 2551))

ref instance-attribute

node instance-attribute

__init__(ref, node)

casty.Listing dataclass

Current set of instances for a given service key.

Parameters:

Name Type Description Default
key ServiceKey[M]

The service key this listing is for.

required
instances frozenset[ServiceInstance[M]]

All known instances of the service.

required

Examples:

>>> listing = Listing(key=ServiceKey("counter"), instances=frozenset())
>>> len(listing.instances)
0

key instance-attribute

instances instance-attribute

__init__(key, instances)

casty.Register dataclass

Register a local actor as a service instance.

Parameters:

Name Type Description Default
key ServiceKey[M]

Service key to register under.

required
ref ActorRef[M]

Reference to the actor providing the service.

required

key instance-attribute

ref instance-attribute

__init__(key, ref)

casty.Deregister dataclass

Remove a local actor from the service registry.

Parameters:

Name Type Description Default
key ServiceKey[M]

Service key to deregister from.

required
ref ActorRef[M]

Reference to the actor to remove.

required

key instance-attribute

ref instance-attribute

__init__(key, ref)

casty.Subscribe dataclass

Subscribe to changes in a service key's instance set.

The subscriber immediately receives the current Listing and is notified on every subsequent change.

Parameters:

Name Type Description Default
key ServiceKey[M]

Service key to watch.

required
reply_to ActorRef[Listing[M]]

Where to send Listing updates.

required

key instance-attribute

reply_to instance-attribute

__init__(key, reply_to)

casty.Find dataclass

One-shot query for the current instances of a service key.

Parameters:

Name Type Description Default
key ServiceKey[M]

Service key to look up.

required
reply_to ActorRef[Listing[M]]

Where to send the current Listing.

required

key instance-attribute

reply_to instance-attribute

__init__(key, reply_to)