1.0.6 • Published 10 years ago

moshi-moshi v1.0.6

Weekly downloads
1
License
WTFPL
Repository
github
Last release
10 years ago

README desu

THIS IS A EXPERIMENTAL PACKAGE

Each created queue has one response queue, which receive messages from the sender, while asker wait for response on response queue, it's like LeanKit-Labs/wascally but using postwait/node-amqp as backend and made by a totally amateur programmer :bowtie:

And yes, it's a unexpected behaviour of an message queue service, unless we are talking about RPC. But who cares?

Proposal

var phone = require('moshi-moshi');

// receiver
phone('exchange', /*...amqp connection info*/)
  .then(function(connection) {
    connection
      .withQueue('the-queue', ['notice' /* routing keys */], /* queue options */) // return event emitter, is that wrong? Yes. Maybe a Stream could be cooler.
      .on('message', function(message) {
        message.reply('SENPAI NOTICED ME'); // auto acknowledge of `message`
      })
      .on('yaddayaddayadda', function(yaddayaddayadda) {
        yaddayaddayadda.yaddayaddayadda();
      });
  })
  .catch(function(error) {
    console.error("HOLY C##P");
  });

// sender
phone('exchange', /*...amqp connection info*/)
  .then(function(connection) {
    connection
      .askFor('notice')
      .timeout(1000) // timeout from bluebird
      .then(function(reply) {
        console.log(reply.body);
      })
      .catch(function(error) {
        console.error("uh-oh");
      });
  })
  .catch(function(error) {
    console.error("HOLY C##P");
  });

TODO

  • CANCELLABLE EVERYTHING
  • code style
  • find a good naming convention
1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago