Reputation: 497
My requirement is to use named agents. Basically one agent per record with a custom id. Can we query the Agent's name across application instances and BEAM ? I mean that if we have 2 instances of an app on 2 different BEAM machines we need to make sure that we have only one
agent per record. Not more. How can I achieve this?
Upvotes: 0
Views: 56
Reputation: 121000
Agent
is basically a GenServer
. The latter has three options to register it’s name. Both {:global, term}
and {:via, module, term}
register the name globally.
Of course, all the nodes should be connected for this to work.
To make it easier to address globally registered processes, one might use Registry
, although in this particular case {:global, name}
should be fine enough.
Upvotes: 1