mxriverlynn / rabbus

A micro-service bus with built-in messaging patterns, for NodeJS and RabbitMQ
116 stars 26 forks source link

Rabbus.Topology is not a constructor? #27

Closed 24601 closed 8 years ago

24601 commented 8 years ago

We are having an issue where using exactly the methods demonstrated in the docs we are getting an error about Rabbus.Topology not being a constructor.

So, given:

var senderTop = new Rabbus.Topology({
  exchange: "send-rec.ex",
  routingKey: "send-rec.key"
});

function SomeSender(){
  Rabbus.Sender.call(this, rabbot, senderTop);
}

util.inherits(SomeSender, Rabbus.Sender);

We would expect that senderTop will be a "Topology" object.

Instead, we receive the following error:

/Users/spartacus/workspace/voltaire/rabbus/voltaire-lx-svc/lib/job-handler.js:13
    var senderTop = new Rabbus.Topology(rabbot, {
                    ^

TypeError: Rabbus.Topology is not a constructor
    at jobHandler (/Users/spartacus/workspace/voltaire/rabbus/voltaire-lx-svc/lib/job-handler.js:13:21)
    at Object.<anonymous> (/Users/spartacus/workspace/voltaire/rabbus/voltaire-lx-svc/lib/job-handler.js:44:18)

Opening this in the debugger and inspecting the Rabbus object and the _proto there shows us that indeed this is correct, there is .Topology on the Rabbus object.

We made a few changes go get it to work:

In lib/index.js we added Topology to the rabbus object for export like so:

var Topology = require("../lib/topology/index.js")

var rabbus = {
  Requester: Requester,
  Responder: Responder,
  Sender: Sender,
  Receiver: Receiver,
  Publisher: Publisher,
  Subscriber: Subscriber,
  Topology: Topology,
};

module.exports = rabbus;

and instead of using, as the docs say a single arg to Topology, we do this:

var senderTop = new Rabbus.Topology(rabbot, {
        exchange: process.env.VT_ENVIRONMENT + "-vt-juror-analysis-x",
        queue: process.env.VT_ENVIRONMENT + "-search-place",
        routingKey: process.env.VT_ENVIRONMENT + "-search-place"
    });

This seems to clear the error. Any advice on something we maybe missing or doing wrong? We couldn't seem to figure it out so hacked up this solution that (so far) seems to work.

@gittristan will be submitting a PR from our fork where we made these changes that we'll reference from here shortly.

UPDATE: @gittristan has filed PR #28

mxriverlynn commented 8 years ago

oops! that's definitely not right. thanks for the very detailed description of the problem and the pull request! I'll dig into these and get a new release done as soon as I can (most likely tomorrow).

24601 commented 8 years ago

@derickbailey, thank you very very much. We really appreciate it and so far love rabbus. The last version of our backend used rabbot a lot and excited to have another great layer of abstraction on top of it!

mxriverlynn commented 8 years ago

got that pulled in and v0.8.2 is up on npm. thanks!