moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

mosca and ascoltatori require unused modules #684

Closed jemmyw closed 6 years ago

jemmyw commented 6 years ago

If I'm using redis for persistence then I don't want mosca to load the mongodb drivers, for example.

This has come about because I want to run mosca in a resource constrained environment where some of the optional modules cannot be compiled, and I don't want to install more than is required.

I have created a patch for mosca https://github.com/mcollina/mosca/pull/683 and for ascoltatori https://github.com/mcollina/ascoltatori/pull/180 that simply wrap the classes and persistence functions in another function, thus deferring the require call.

https://github.com/mcollina/ascoltatori/pull/180 https://github.com/mcollina/mosca/pull/683

I'm not expecting these to be suitable for merging as I have not run tests, and they will inevitably break the public APIs. I'm just putting this as an example in the hope of discussion for a better solution. These changes have allowed me to get up and running.

jemmyw commented 6 years ago

using aedes instead