Coaktion / evolutty

Evolutty is an asynchronous message dispatcher for concurrent tasks processing.

Home Page:https://coaktion.github.io/evolutty/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Evolutty

npm Build Status Maintainability Code Climate coverage

evolutty is an asynchronous message dispatcher for concurrent tasks processing, with the following features:

  • Encourages decoupling from message providers and consumers
  • Easy to extend and customize
  • Easy error handling, including integration with sentry
  • Easy to create one or multiple services
  • Generic Handlers
  • Bull integration
  • AWS SQS integration
  • RabbitMQ integration

ℹ️ Currently, BullMQ, RabbitMQ and AWS SQS are supported

Installation

npm i @coaktion/evolutty

Usage

import {
  BullMQHandler,
  BullMQRouter,
  EvoluttyManager,
  RabbitMQHandler,
  RabbitMQRouter,
  SQSHandler,
  SQSRouter
} from '@coaktion/evolutty';

export class MyBullHandler extends BullMQHandler {
  async handle(content: object, metadata: object): Promise<boolean> {
    // code here
    return true;
  }
}

export class MySQSHandler extends SQSHandler {
  async handle(content: object, metadata: object): Promise<boolean> {
    // code here
    return true;
  }
}

export class MyRabbitMQHandler extends RabbitMQHandler {
  async handle(content: object, metadata: object): Promise<boolean> {
    // code here
    return true;
  }
}

const routers = [
  {
    routeType: BullMQRouter,
    handler: MyBullHandler,
    queueName: 'my_queue_bull'
  },
  {
    routeType: SQSRouter,
    handler: MySQSHandler,
    routeParams: {
      accessKeyId: 'test',
      secretAccessKey: 'test',
      region: 'us-east-1',
      visibilityTimeout: 10
    },
    queueName: 'my_queue_sqs'
  },
  {
    routeType: RabbitMQRouter,
    handler: MyRabbitMQHandler,
    queueName: 'my_queue_rabbitmq',
    routeParams: {
      username: 'rabbit_user',
      password: '*******',
      debug: true
    }
  }
];

const manager = new EvoluttyManager(routers);
manager.start();

Observations

  • The queueName option is used as a prefix to fetch queues when the prefixBasedQueues option is equals to true on SQS route params (default is false)

  • You can also customize the logger by setting the environment variables in local.env file:

LOG_LEVEL=debug # default is info
LOG_FILE_PATH=my_app.log # file that will store the logs if LOG_TRANSPORTS contains file
LOG_TRANSPORTS=console,file # comma separated values (currently only console and file are supported)
LOG_FORMAT=json # json or simple

License

Evolutty is MIT

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

About

Evolutty is an asynchronous message dispatcher for concurrent tasks processing.

https://coaktion.github.io/evolutty/

License:MIT License


Languages

Language:TypeScript 98.2%Language:Shell 1.8%