Cyclium.DynamicActor (Cyclium v0.1.8)

Copy Markdown View Source

Generic actor module for DB-defined agents.

Unlike compiled actors that use use Cyclium.Actor with DSL macros, DynamicActor is a single GenServer module that can serve any number of actor instances. Each instance is differentiated by its init args (config map and expectations list).

Starting a dynamic actor

DynamicSupervisor.start_child(Cyclium.ActorSupervisor, {
  Cyclium.DynamicActor,
  name: :my_dynamic_actor,
  config: %{actor_id: :my_actor, domain: :monitoring, ...},
  expectations: [{:check_health, [trigger: {:schedule, 60_000}, ...]}]
})

How it works

DynamicActor delegates all GenServer callbacks to Cyclium.Actor.Server, which is the same module that handles compiled actors. The only difference is that config and expectations come from init args rather than compiled module attributes.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)