0.7.1 • Published 8 years ago

uva-amqp v0.7.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

uva-amqp

The uva RPC interface implementation for AMQP.

Dependency Status Build Status npm version Coverage Status

Installation

npm install --save uva-amqp

Usage

Create a microservice for mathematical calculations and implement some remote methods.

const uva = require('uva-amqp')

uva.server({
  channel: 'mathOperations',
  amqpURL: 'amqp://guest:guest@localhost:5672',
})
.then(server => {
  server.addMethods({
    sum(a, b, cb) {
      cb(null, a + b)
    },
    factorial(n, cb) {
      let f = 1
      for (let i = 2; i <= n; i++) {
        f *= i
      }
      cb(null, f)
    },
  })
  server.start()
})

Create a client for the math microservice and call some of its remote methods.

const uva = require('uva-amqp')

uva.client({
  channel: 'mathOperations',
  amqpURL: 'amqp://guest:guest@localhost:5672',
})
.then(math => {
  math.sum(12, 2, function(err, sum) {
    console.log(sum)
  })

  /* if the last argument is not a callback, the function will return a promise */
  math.factorial(10).then(function(result) {
    console.log(result)
  }, function(err) {
    console.error(err)
  })
})

License

The MIT License (MIT)

0.7.1

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago