ericholiveira / studio-cluster

Auto cluster for Studio framework
23 stars 4 forks source link

Publishers are broken #12

Closed danp3d closed 8 years ago

danp3d commented 8 years ago

UPDATE: It's not broken. I was using it the wrong way. I was using it as:

studio.use(studioCluster.publishers.redis(...))

instead of this:

studio.use(studioCluster({
    rpcPort: port,
    publisher: studioCluster.publishers.redis(...)
})

Hi,

First of all, congrats on the work here. The framework is pretty cool.

To the issue: I'm using the Redis publisher, and found a problem on it. The middleware returned by the redis publisher contains a wrong signature.

module.exports = function (rpcPort, opt) {
    return function(Studio) {...

But the 'use' function in Studio actually calls the middleware with two parameters - and Studio is the second.

use : function(plugin,filter){
    var self = this;
    return plugin({ onStart: ..., onStop: ..., interceptSend: ... }, Studio)
...

It's a very simple fix. I'm including a patch. (Please note I haven't checked the other middleware functions, just the Publisher ones)

fix-middleware-signature.patch.zip

In the meantime, I'm using the following hack to get it working (I can't change the source code inside node_modules since it's actually an automated build using docker):

"use strict";

const Promise = require('bluebird')
if (!Object.prototype.promise)
    Object.defineProperty(Object.prototype, 'promise', { value: Promise, writable: true })

// load Studio and Studio-Cluster and use it as usual

This is just to ensure that the options object will have a 'promise' property so the app can limp along.

Cheers

ericholiveira commented 8 years ago

Thx @danp3d , great to know you found your way around it. So, as you're just using it wrong i will close this issue, ok? Also, a few days ago i started a slack channel for those using Studio and i would like to invite you to join us. Its also the best place to have a direct discussion on new features and roadmap... If you have interest: https://studiojs.herokuapp.com/