Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davibe/comm
Simple microservice communication library
https://github.com/davibe/comm
Last synced: about 1 month ago
JSON representation
Simple microservice communication library
- Host: GitHub
- URL: https://github.com/davibe/comm
- Owner: davibe
- Created: 2016-12-13T12:55:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-13T16:23:56.000Z (about 8 years ago)
- Last Synced: 2024-10-13T17:56:07.087Z (3 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
README
------*WIP*
Simple microservice communication library based on 'amqp-as-promised'
- configuration based on env vars
- simple interface wrapping function, arguments and errors### Example
Microservices below will connect to RabbitMQ at "amqp://localhost:5672//?heartbeat=10".
They can be launched using node 7 with --harmony option
#### service1.js
```javascript
const comm = require('comm')comm.expose('service1', 'hi', async (name, surname) => {
await new Promise(r => setTimeout(r, 1000))
return { hi: `${name} ${surname}` }
})
```#### service2.js
```javascript
const comm = require('comm')const main = async () => {
const result = await comm.call('service1', 'hi', 'Pluto', 'Brau')
console.log(result) // -> { hi: "Pluto Brau"}
}if (!process.parent) { main() }
```### Tests
```bash
docker-compose stop -t1; docker-compose rm -f ; docker-compose build ; docker-compose up test
```