hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

multiple plugin instances #18

Closed larryhengl closed 9 years ago

larryhengl commented 9 years ago

Hapi noob here. Trying to use multiple instances of the mysql plugin to setup different db connection pools accessible to the same route (for doing federated queries). It's not immediately obvious where in the Glue manifest to put the attributes.multiple=true. And once it is set, what is the best way to reference a specific plugin instance being that they have the same plugin name? Any tips would be appreciated. thx, Larry

FennNaten commented 9 years ago

Hi,
I'm not a contributor but I'm passing by and I think I can answer your question (even if you may have found the answer yourself considered how much time has passed since you asked).
Glue is not responsible for the support of multiple registrations of a plugin: it should be an attribute of the plugin itself, which must in this case expose its functionality in a way that works with it.
If the plugin you use is this one: https://github.com/seldo/hapi-mysql , then you can see in its index.js that it doesn't offer the attributes.multiple, and that the way it's built is not compatible with multiple registration (each registration would overload the previous pool with the new one).
If you really need this functionality, you can open an issue in the repo of the plugin or maybe write your own.

csrl commented 9 years ago

"attributes.multiple" is not a value that can be set via an API call. As FennNaten pointed, out the plugin must itself set the flag and support the feature. The glue documentation is simply pointing that requirement out.

For more details see Hapi's Server.register docs http://hapijs.com/api#serverregisterplugins-options-callback and also the Hapi Plugin docs http://hapijs.com/api#plugins

The https://github.com/hapijs/discuss support group is a good general place for questions that touch on using Hapi.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.