ExAgent. Conversations. Registry behaviour
(ExAgent v3.0.0)
View Source
The registry behind ExAgent.Conversations: where a conversation's owner is
named and found.
Stability — Stable.
registry: :local (the default, scope/0 :node) names owners in a
partitioned Registry on this node. registry: :global names them with
:global across the connected cluster (scope/0 :cluster). A host
adapter is {module, opts} implementing these callbacks; opts reach
child_specs/2 only.
A registry is best effort: during a netsplit each side can activate the same
conversation. Only the Store arbitrates, so a :cluster registry requires
Server options with :continuation and a Store whose
ExAgent.Store.capabilities/1 is %{continuation: :atomic, durability: :durable}; ExAgent.Conversations.ensure/3 raises ArgumentError
otherwise. With them, at most one owner confirms each turn: the other one
gets :superseded before any model or tool IO and stops.
When a partition heals, :global keeps the owner on the node whose name
sorts first and tells the other one, which cancels its queued requests and
stops with {:shutdown, :superseded} once it has no run in progress (after
finishing the current one). ExAgent.Conversations.call/4 then retries
against the owner that was kept.
Summary
Callbacks
Children started under the Conversations supervisor, before its owners.
:node for a registry local to each node, :cluster for one shared by connected nodes.
The :via name an owner registers with.
Find the registered owner, local or remote, or return nil.
With a finite timeout, ExAgent.Conversations.ensure/3 and
ExAgent.Conversations.call/4 can run a host adapter's lookup in a separate
process that is stopped at the deadline.
Types
@type key() :: ExAgent.Conversations.key()
Callbacks
@callback child_specs(name :: atom(), opts :: keyword()) :: [Supervisor.child_spec()]
Children started under the Conversations supervisor, before its owners.
@callback scope() :: :node | :cluster
:node for a registry local to each node, :cluster for one shared by connected nodes.
The :via name an owner registers with.
Find the registered owner, local or remote, or return nil.
With a finite timeout, ExAgent.Conversations.ensure/3 and
ExAgent.Conversations.call/4 can run a host adapter's lookup in a separate
process that is stopped at the deadline.