ostinelli / syn

A scalable global Process Registry and Process Group manager for Erlang and Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to add `on_exit` callback for group processes in the same manner as for registry one

tank-bohr opened this issue · comments

I needed this for the use case from README

Typical Use Case: a chatroom.

To send a system message about user leaving chatroom

Thank you for the suggestion.

We can add this, but for your specific case you probably have your transport's callback when a user disconnects, and use that.

Would be nice if you could add callbacks for specific groups, instead of adding it to sys.config like you would do for the registry. Just looked through the source and if I'm understanding it correctly, we could simply add a genserver call to add a callback to the group state, and then execute any callbacks on the leave / handle_info flows.

I might be wrong since I just started using this (really liking it), but having this feature would be nice.

@kwrooijen thank you for your feedback, this can be another enhancement on its own.

What suggested by @tank-bohr is now implemented in master. Can you please check?

@kwrooijen, if you're interested can you please open another dedicated issue for your request so that we can properly track it?

@ostinelli After re-evaluating my own problem I've figured out a better way to solve it. So I personally don't need this feature. So I'll leave it up to you if you actually think this feature would fit syn or not. Thanks!

@ostinelli Thanks a lot for your work! In spite of the fact that I used your advise about transport's callback it could be rather useful feature. And for consistency sane (the group processes now have the same api as registry ones). As my proposal had been implemented entirely I think this issue could be closed. Thanks!