@betit/orion
Version:
Pluggable microservice framework
78 lines (52 loc) • 2.08 kB
Markdown
[![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![NPM Version][npm-image]][npm-url]
Orion is a pluggable framework for microservices.
Following "batteries included but removable" design philosophy. Providing sane default implementations, but everything is swappable. Comes with built in support for various transports and codecs.
- **Async communication**: event driven architecture (pub/sub)
- **Sync communication**: request-response transport layer
- **RPC**: clean and simple interface to build services
## Components
- **Transport**: provides an interface for sync request/response communication
- **Codec**: used for encoding and decoding messages before transporting across the wire
- **Service**: provides an interface to name your service and register request handlers
- **Client**: provides an interface to make requests to services
### Built-in components
- **Transports**: NATS _(default)_
- **Codecs**: JSON _(default)_, MessagePack
## Example
Service:
```javascript
const orion = require('@betit/orion');
const service = new orion.Service('calc');
service.handle('add', (req, reply) => {
reply(null, parseInt(req.params.a) + parseInt(req.params.b));
});
service.listen(() => {
console.log(`Service started: ${service}`);
});
```
Client:
```javascript
const orion = require('@betit/orion');
const client = new orion.Client({ service: 'calc' });
client.call('add', { a: 3, b: 2 }, (err, res) => {
console.log(err, res);
client.close();
});
```
Check out the [examples](examples) folder for more examples.
```
$ docker run -p 4222:4222 -p 8222:8222 -d nats
$ npm install
$ npm test
```
[](LICENSE)
[]: https://img.shields.io/travis/betit/orion.svg
[]: https://travis-ci.org/betit/orion
[]: https://img.shields.io/codecov/c/github/betit/orion.svg
[]: https://codecov.io/gh/betit/orion
[]: https://img.shields.io/npm/v/@betit/orion.svg
[]: https://www.npmjs.com/package/@betit/orion