View Source Actors.Registry.ActorRegistry (spawn v2.0.0-RC10)

The ActorRegistry module provides a registry for actor entities.

It allows for registering and looking up actors and also provides methods for adding and removing invocation requests for actors.

Summary

Functions

Retrieves a list of hosts associated with a given actor. Parameters

Fetch current entities of the service. Returns HostActor with Host and specific actor.

Register member entities to the ActorRegistry. Returns Cluster with all Host members.

Functions

get_hosts_by_actor(actor_id, opts \\ [])

@spec get_hosts_by_actor(Spawn.Actors.ActorId.t(), Keyword.t()) ::
  {:ok, Member.t()} | {:not_found, []}

Retrieves a list of hosts associated with a given actor. Parameters

actor_id (%ActorId{}): The ID of the actor. opts (Keyword, optional): Options for the function.

:parent (boolean): If true, filter hosts by parent; otherwise, filter by name.

Returns

: A tuple with :ok and a list of hosts. {:not_found, []}: If no hosts are found.

Examples

actor_id = %ActorId{parent: "parent", name: "name"}
opts = [parent: true]
{:ok, hosts} = Actors.Registry.ActorRegistry.get_hosts_by_actor(actor_id, opts)

lookup(id, opts \\ [])

(since 0.1.0)
@spec lookup(Spawn.Actors.ActorId.t(), Keyword.t()) ::
  {:ok, Actors.Registry.HostActor.t()} | {:not_found, []}

Fetch current entities of the service. Returns HostActor with Host and specific actor.

register(hosts)

(since 0.1.0)
@spec register([Actors.Registry.HostActor.t()]) :: :ok

Register member entities to the ActorRegistry. Returns Cluster with all Host members.

Examples

iex> hosts = [%HostActor{node: Node.self(), actor: actor, opts: []}}]
iex> ActorRegistry.register(hosts)
:ok