Cyclium.DynamicActor.Watcher (Cyclium v0.2.0)

Copy Markdown View Source

Optional GenServer that subscribes to Bus events and automatically refreshes dynamic actors and dynamic workflows when their DB definitions change.

Events handled

Agent definitions

  • "agent_definition.created" — loads and starts a new dynamic actor
  • "agent_definition.updated" — drains, then reloads the actor from DB
  • "agent_definition.disabled" — drains and stops the actor

Workflow definitions

  • "workflow_definition.created" — loads and registers a new dynamic workflow
  • "workflow_definition.updated" — reloads the workflow from DB
  • "workflow_definition.disabled" — unregisters the workflow

Usage

Add to your supervision tree if you want automatic refresh:

children = [
  # ... other children ...
  Cyclium.DynamicActor.Watcher
]

Then broadcast events from your application when definitions change:

Cyclium.Bus.broadcast("agent_definition.created", %{actor_id: "my_monitor"})
Cyclium.Bus.broadcast("workflow_definition.created", %{workflow_id: "onboarding"})

If you don't want automatic refresh, call lifecycle/loader functions directly.

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 \\ [])