Skip to content

Address

casty.ActorAddress dataclass

Immutable address identifying an actor within a Casty system.

Uses a URI scheme: casty://system@host:port/path for remote actors and casty://system/path for local actors.

Parameters:

Name Type Description Default
system str

Name of the actor system.

required
path str

Slash-prefixed path of the actor within the system.

required
host str or None

Hostname for remote addresses, None for local.

None
port int or None

TCP port for remote addresses, None for local.

None

Examples:

>>> local = ActorAddress(system="my-system", path="/user/counter")
>>> local.is_local
True
>>> local.to_uri()
'casty://my-system/user/counter'
>>> remote = ActorAddress(system="cluster", path="/user/worker", host="10.0.0.1", port=25520)
>>> remote.to_uri()
'casty://cluster@10.0.0.1:25520/user/worker'

system instance-attribute

path instance-attribute

host = None class-attribute instance-attribute

port = None class-attribute instance-attribute

node_id = None class-attribute instance-attribute

is_local property

Return True if this address has no host (i.e. is local).

Returns:

Type Description
bool

Examples:

>>> ActorAddress(system="sys", path="/a").is_local
True
>>> ActorAddress(system="sys", path="/a", host="h", port=1).is_local
False

to_uri()

Serialize the address to a casty:// URI string.

Returns:

Type Description
str

URI representation of the address.

Examples:

>>> addr = ActorAddress(system="sys", path="/user/greeter", host="localhost", port=9000)
>>> addr.to_uri()
'casty://sys@localhost:9000/user/greeter'

from_uri(uri) staticmethod

Parse a casty:// URI into an ActorAddress.

Parameters:

Name Type Description Default
uri str

A URI of the form casty://system@host:port/path (remote) or casty://system/path (local).

required

Returns:

Type Description
ActorAddress

Raises:

Type Description
ValueError

If uri does not match either pattern.

Examples:

>>> addr = ActorAddress.from_uri("casty://sys@127.0.0.1:8000/user/actor")
>>> addr.host
'127.0.0.1'
>>> addr.path
'/user/actor'

__init__(system, path, host=None, port=None, node_id=None)