Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Dvs-Bilisim/dot-bee
https://github.com/Dvs-Bilisim/dot-bee
bee-queue concurrency fault-tolerance microservice-framework microservice-toolkit microservices rpc service-discovery soa
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Dvs-Bilisim/dot-bee
- Owner: dot-microservices
- License: mit
- Archived: true
- Created: 2019-07-24T11:54:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-01T06:59:50.000Z (almost 5 years ago)
- Last Synced: 2024-04-10T11:14:28.240Z (7 months ago)
- Topics: bee-queue, concurrency, fault-tolerance, microservice-framework, microservice-toolkit, microservices, rpc, service-discovery, soa
- Language: JavaScript
- Homepage: https://github.com/umuplus/beems
- Size: 254 KB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dot-bee
a bee-queue based minimalist toolkit for building fast, decentralized, scalable and fault tolerant microservices
## Motivation
major difference from other [dot-rest](https://github.com/Dvs-Bilisim/dot-rest) or
[dot-ws](https://github.com/Dvs-Bilisim/dot-ws) projects is that
it works on top of a redis-based solid message queue called [bee-queue](https://github.com/bee-queue/bee-queue).
because of that, [clerq](https://github.com/Dvs-Bilisim/clerq) based service discovery is out of the architecture.on the other hand, original [dot](https://github.com/Dvs-Bilisim/dot) has auto service discovery feature and
because of its dependencies, it has completely different use cases.## Install
```bash
npm i --save dot-bee
```You can also clone this repository and make use of it yourself.
```bash
git clone https://github.com/Dvs-Bilisim/dot-bee.git
cd dot-bee
npm i
npm test
```Before running tests, please make sure that you have Redis available on localhost.
If you don't know how to do that temporarily, please use following command to run it via docker.```bash
docker run -p 6379:6379 --name dot_redis redis:4-alpine
```## Configuration
- **bee:** options for initializing a bee queue instance. please see more details at [Bee Queue Settings](https://github.com/bee-queue/bee-queue#settings).
- **job:** options for creating a bee queue job. only setId, retries, backoff, delayUntil and timeout methods allowed. please see more details at [Bee Queue Job Settings](https://github.com/bee-queue/bee-queue#methods-1).
- **pino:** options for pino logger. it's { "level": "error" } by default.## Server Methods
- **.addServices(services, concurrency = 1, options):** adds list of services and automatically creates their queues and consumers
- **.addService(service, concurrency = 1, options):** adds a new service and automatically creates related queue and its consumer
- **.close():** stops all existing queues for a clean shutdown
- **.destroy():** removes everything about existing queues from redis## Client Methods
- **.acceptServices(services, options):** accepts existing services to send jobs
- **.acceptService(service, options):** accepts an existing service to send jobs
- **.forward(service, method, data, options):** sends a new job to an existing service
- **.send(service, method, data, options):** sends a new job to an existing service and retrieves its response
- **.close():** stops all existing queues for a clean shutdown## Examples
```js
const { Client, Server } = require('dot-bee');class Service {
static _name() {
return 'myService';
}static async echo(job) {
return job.data;
}
}const client = new Client();
const server = new Server();
server.addServices([ Service ]);
client.acceptServices([ 'myService' ]);const r = await client.send('test', 'echo', { t: Date.now() });
console.log(r);await client.close();
await server.destroy();
await server.close();
```## Optional Job Configuration
please see more details at [Bee Queue Job Settings](https://github.com/bee-queue/bee-queue#methods-1).
```js
await client.send('test', 'echo', { t: Date.now() }, {
setId: 'my-custom-job-id',
retries: 2,
backoff: [ 'fixed', 1000 ],
delayUntil: Date.parse('2082-08-23T00:00:01.000Z'),
timeout: 10000
});
```