GithubHelp home page GithubHelp logo

coaktion / evolutty Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 1.0 584 KB

Evolutty is an asynchronous message dispatcher for concurrent tasks processing.

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

License: MIT License

TypeScript 98.25% Shell 1.75%
bull bullmq queue redis typescript sqs sqs-consumer rabbitmq rabbitmq-client rabbitmq-consumer

evolutty's Introduction

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

evolutty's People

Contributors

dependabot[bot] avatar inaciogu avatar paulo-tinoco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

evolutty's Issues

[Bug]: RabbitMQ nack function

Describe the bug

When the nack function is triggered, the message is not sent back to the queue with the "ready" status. So, the consumer cannot try to consume it again.

Your minimal, reproducible example

//

Steps to reproduce

  1. Start the server with RabbitMQ.
  2. Create a message in the queue.
  3. Throw an exception in handle method.
  4. Inspect the queue to see the behavior

Expected behavior

The message should to go back to the queue, but it is not happening.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS [linux ubuntu 20.04]
  • Node 16.16.0

Package version

v1.2.0

Additional context

No response

[Bug]: SQS message translator

Describe the bug

In the SQS message translator class, the message content, except the metadata, is taken from the Message property inside de MessageBody. This behavior makes the user to have to pass a Message property inside the MessageBody when sending a message to the queue. When this property isnt passed, evolutty throws an error in SQS message translator. But the sqs client doesnt have this rule, it allows the user to pass any properties inside the MessageBody, and doesnt asks for the Message property.

Your minimal, reproducible example

//

Steps to reproduce

  1. Create a service using evolutty.
  2. Use the SQS handler to consume a queue.
  3. Send a message without the property Message inside the MessageBody

Expected behavior

I expected the message body could have any format, but according to the message translator implementation, I have to include the message content inside a Message property to the service works without errors

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS Linux ubuntu
  • Node version v1815.0

Package version

v1.2.1

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.