Multi aliases registration for process.
loguntsov opened this issue · comments
I think the multi aliases feature should be live, because only library users can know real purpose of registration.
I need register process by several aliases. It is very useful for me.
I can make patch for that, but not sure that it will be included in main code.
i met:
1> syn:register(a, self()).
ok
2> syn:register(b, self()).
{error,pid_already_registered}
how i can use syn for multi aliases registration ?
thanks.
The default behaviour of Syn is to uniquely identify a process by its name. This is consistent with Erlang's register functionalities:
1> register(test, self()).
true
2> register(test2, self()).
** exception error: bad argument
in function register/2
called as register(test2,<0.33.0>)
That being said, I can understand your request and my proposal would be to set an option on Syn on whether to allow for registering aliases. Something along the lines of:
{registry_allow_aliases, true}
Would that work for you?
Hi.
I got your point. I think the global option is not good thing, because your registry will be not pure and behaviour of it will depend from external option.
I think no reason to support same behavior as from global module. Just give us useful library :)
So what do you think if I will develop this logic by default for your library?
"Not pure", because a behaviour depends on an option? In my opinion this is exactly what options are for: customize a behaviour. It's the same as enforcing uniqueness of a key in a system: this may be optional.
I'm sorry that you want me to "just give" you a "useful library" :) but as I've said before: the default behaviour of Syn already is and will continue to be (at least in backwards compatible versions 1.x.x) to register one process per one registration Key. Not only I think this is a safe default behaviour, but also I cannot and won't break backwards compatibility.
I've offered to provide a different behaviour based on an optional setting, however you disagree with my proposal and would like to change the current default behaviour (which would break backwards compatibility, something I won't do). Hence, I would like to see if other users are interested in this feature and we can discuss more then. For now, thank you for your input :)
I meant that this option will allow confusion in behaviour of library. It can make mistakes in the future (human factor).
Thanks for your opinion.
Anyway I think that will fork your library for my purposes.
Ok. :) I'll keep this here open for now.
No further action, so closing. Thank you for your proposal.
Аll actions are inside my repository: https://github.com/loguntsov/syn
You can learn all changes, and if you need i can make pull request.
Thanks.
Sorry to comment on such an old issue, but I basically pretty much need the same thing.
Just having an option to allow aliases would totally work for me.
Implemented in v2, thank you.