dot-bee
a bee-queue based minimalist toolkit for building fast, decentralized, scalable and fault tolerant microservices
Motivation
major difference from other dot-rest or dot-ws projects is that it works on top of a redis-based solid message queue called bee-queue. because of that, clerq based service discovery is out of the architecture.
on the other hand, original dot has auto service discovery feature and because of its dependencies, it has completely different use cases.
Install
npm i --save dot-bee
You can also clone this repository and make use of it yourself.
git clone https://github.com/Dvs-Bilisim/dot-bee.gitcd dot-beenpm inpm 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.
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.
- 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.
- 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
const Client Server = ; static { return 'myService'; } static async { return jobdata; } const client = ;const server = ;server;client; const r = await client;console; await client;await server;await server;
Optional Job Configuration
please see more details at Bee Queue Job Settings.
await client;