Closed hachreak closed 8 years ago
Hi there,
that's a good point. We decided to have it that way to keep it as simple as possible. Moreover the hooks are called in either the session (connection) or the queue process, which would require to copy the context around. You could e.g use a shared ETS table to store and retrieve the context.
How does the context in your case look like?
Cheers!
I'd like to have something like in cowboy, webmachine or emqtt.
You have a init()
function that returns the context used by your handlers.
In your example app you have only the pool name defined by a macro. In my case I have not something really complicated and, actually, it's something "static", but I have different submodules to initialize and not depending by me. I normally call the init function of any submodule and collect all context.
Yes, I agree it might make sense. I've to discuss this with @larshesel and @afa. However I still see some issues with the current implementation that wouldn't allow to keep the same context among all hooks, e.g. the on_client_offline/on_client_gone are called in a different process than on_register and on_publish. For now I would go over a shared ETS or if you're really brave think about using the process dictionary for this.
I'm not sure I understand what you mean.
For sure, I think make sense that every behaviour have a separate init()
function.
And vmq_plugin
should take care of collect them and pass the correct context depending of which behaviour is calling.
Hi @hachreak
Thanks for your patience. We've had a quick discussion on this and came to the conclusion that we can't focus on this enhancement before version 1.0 is released. It would imply too many changes. While maybe a bit cumbersome, what you want to do is already possible today. Please get in touch over email (info[at]vernemq.com) if you require further assistance for this.
Cheers, Andre
Hi, I'm trying to implement a new plugin for ACL/Auth. On implementing the hook
auth_on_register()
I remain surprised that you are not passing the context. In the plugin initialization I need to initialize many things that I need on myauth_on_register()
implementation. There is a way to do that?Thanks