remost

0.0.6 • Public • Published

Remost (0.0.6)

Http RPC platform

Install

npm install remost

Use

Restful and RabbitMQ

You can use Restful(express server) or RabbitMQ

Restful

const Binder = require('remost').Binder
let binder = new Binder()
binder.bind(3000,()=>{

})

const Caller = require('remost').Caller
let caller = new Caller('http://localhost:3000')

RabbitMQ

const Binder = require('remost/rabbitmq_protocol').Binder
let binder = new Binder('test_queue','amqp://localhost')


const Caller = require('remost/rabbitmq_protocol').Caller
let caller = new Caller('test_queue','amqp://localhost')
caller.onReady(()=>{
  // ...
})

Binder

You can user Binder to bind function to call by Caller.
Binded function can return value or one Promise

const Binder = require('remost').Binder

let binder = new Binder()
let bind = binder.bind

bind('sum',(a,b)=>{
  return a + b;
})

bind('multi',(a,b)=>{
  return new Promise((resolve,reject)=>{
      resolve(a * b)
    })
})

binder.bind(3000,()=>{
    console.log("Server listen on port 3000")
})

Caller

You can call binded function above

const Caller = require('remost').Caller
let caller = new Caller('http://localhost:3000')
let call = caller.call

call('sum',1,2).then((result)=>{
  console.log(result)
},(e)=>{
    console.error(e)
})

call('multi',2,4).then((result)=>{
  console.log(result)
},(e)=>{
  console.error(e)
})

Auth

Email: hieunv495@gmail.com

Readme

Keywords

Package Sidebar

Install

npm i remost

Weekly Downloads

1

Version

0.0.6

License

ISC

Last publish

Collaborators

  • hieunv495