A Node.js microservices toolkit for the NATS messaging system
- Node: 4.x, 5.x, 6.x, 7.x
- Documentation: https://hemerajs.github.io/hemera/
- Website: https://hemerajs.github.io/hemera-site/
- Lead Maintainer: Dustin Deus
Hemera (/ˈhɛmərə/; Ancient Greek: Ἡμέρα [hɛːméra] "day") is a small wrapper around the NATS driver. NATS is a simple, fast and reliable solution for the internal communication of a distributed system. It chooses simplicity and reliability over guaranteed delivery. We want to provide a toolkit to develop micro services in an easy and powerful way. We use bloom filters to provide a pattern matching RPC style. You don't have to worry about the transport. NATS is powerful.
With Hemera you have the best of both worlds. Efficient pattern matching to have the most flexibility in defining your RPC's. It doesn't matter where your server or client lives. You can add the same add as many as you want on different hosts to ensure maximal availability. The only dependency you have is a single binary of 7MB. Mind your own business NATS do the rest for you:
The key features of NATS in combination with Hemera are:
- Lightweight: The Hemera core is small as possible and can be extended by extensions or plugins.
- Location transparency: A service may be instantiated in different locations at different times. An application interacting with an service and does not know the service physical location.
- Service Discovery: You don't need a service discovery all subscriptions are managed by NATS.
- Load Balancing: Requests are load balanced (random) by NATS mechanism of "queue groups".
- Packages: Providing reliable and modern plugins to the community.
- High performant: NATS is able to handle million of requests per second.
- Scalability: Filtering on the subject name enables services to divide work (perhaps with locality) e.g.
topic:auth:germany
. Queue group name allow load balancing of services. - Fault tolerance: Auto-heals when new services are added. Configure cluster mode to be more reliable.
- Auto-pruning: NATS automatically handles a slow consumer and cut it off.
- Pattern driven: Define the signatures of your RPC's in JSON and use the flexibility of pattern-matching.
- PubSub: Hemera supports all features of NATS. This includes wildcards in subjects and normal publish and fanout mechanism.
- Tracing: Any distributed system need good tracing capabilities. We provide support for Zipkin a tracing system which manages both the collection and lookup of this data.
- Monitoring: Your NATS server can be monitored by cli or a dashboard.
- Payload validation: Create your own validator or use existing plugins for Joi and Parambulator.
- Serialization: Use JSON, Msgpack or Avro to serialize your data (dynamic or static).
- Metadata: Transfer metadata across services or attach contextual data to tracing systems.
- Dependencies: NATS is a single binary of 7MB and can be deployed in seconds.
const Hemera = require('nats-hemera')
const HemeraJoi = require('hemera-joi')
const nats = require('nats').connect(authUrl)
const hemera = new Hemera(nats, { logLevel: 'info' })
hemera.use(HemeraJoi)
hemera.ready(() => {
hemera.add({
topic: 'math',
cmd: 'add',
a: Joi.number().required(),
b: Joi.number().required()
}, (req, cb) => {
cb(null, req.a + req.b)
})
hemera.act({
topic: 'math',
cmd: 'add',
a: 1,
b: 2
}, (err, resp) => {
hemera.log.info(resp)
})
})
There is an extensive documentation or look in the Examples.
The hemera
repo is managed as a monorepo, composed of multiple npm packages.
General | Version |
---|---|
nats-hemera | |
hemera-zipkin | |
hemera-store | |
hemera-stats | |
hemera-cli |
Messaging bridges | Version |
---|---|
hemera-rabbitmq | |
hemera-nsq |
Database adapter | Version |
---|---|
hemera-arango-store | |
hemera-sql-store | |
hemera-elasticsearch | |
hemera-couchbase-store | |
hemera-mongo-store |
Payload validation | Version |
---|---|
hemera-joi | |
hemera-parambulator |
Data serialization | Version |
---|---|
hemera-msgpack | |
hemera-avro |
Cache | Version |
---|---|
hemera-redis-cache |
Granting / Authenticating | Version |
---|---|
hemera-jwt-auth |
- Bloomrun - A js pattern matcher based on bloom filters
- Node Nats Driver - Node.js client for NATS, the cloud native messaging system.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Clone repository
npm install
lerna bootstrap
- Install gnats server and make it accesible in your user path.
- Run tests
npm run test
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Dustin Deus - StarpTech
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
Seneca - A microservices toolkit for Node.js.