Git Product home page Git Product logo

brokher's Introduction

Brokher

Brokher is a simple adapter to manage message brokers in your applications.

Motivation

When you need to change your current message broker for other, you may need to change some code in your application. The General Ideia of use brokher is simple change your .env and voila.

Instalation Process

You can find Brokher on npm or yarn simple using:

$ npm install brokher

// or

$ yarn add brokher

Usage

After install Brokher you need to install your base Brokher lib, in this example I will use RabbitMQ with amqlib, so install this lib with

$ npm install amqplib

After installing the lib, you need to config Brokher to use your prefered contract, like bellow:

const Brokher = require('brokher');

async function main () {
  
  const brokher = Brokher.setup('rabbit');
  
  /* for pushing some information */
  await brokher
    .setConnection({ uri: 'rabbitmq_credentials' }) // guest:guest@localhost:5672
    .setChannel('topic', { durable: null })
    .setExchange('logs')
    .setRoutingKey('normal')
    .publish({ message: 'Hello, from Brokher');
    
    
  /* for listing some information */
   await brokher
    .setConnection({ uri: 'rabbitmq_credentials' })
    .setExchange('logs')
    .setQueue('logs-normal')
    .setChannel('topic', { durable: false })
    .subscribe('normal', (message) => {
       console.log(message);
    })
}

The Brokher API

Brokher implements the same contract to every supported Broker, so the principal ideia is don't change your code

Methods

Only subscribe and publish returns Promise. The Brokher methods follow chain pattern and builder pattern, so you can use as you like

setConnection (BrokherConnectionContract) : Brokher

setExchange (BrokherExchange): Brokher

If you use some brokher that is not Exchange Basead, it's Okay, will me ignorated

setChannel (channelName, ChannelOptionsObject) : Brokher

setRoutingKey (routingKeyName): Brokher

publish (messageObject): Promise

subscribe (listingKey, callBackFunction)

The subscribe method receive key that they will listing and callbackFunction that will be trigger when message was received

Support

  • RabbitMQ
  • Apache Kafka
  • Redis
  • Amazon SNS
  • Amazon sqs
  • IBM MQ
  • Microsoft BizTalk
  • Mule ESB
  • Google Cloud Pub/Sub ...

Author

Acidiney Dias

License

MIT

brokher's People

Contributors

acidiney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

andersneto1

brokher's Issues

Issues mal fechadas

Caríssimo @acidiney , reparei que a minha issue anterior foi fechada sem nenhum comentário, pode se faz favor justificar o porque?

imagem

Trata-se de um ORM ou Adapter?

Olá,
Pela descrição desta lib, notei que provavelmente trata-se de um Adapter e não um ORM(Object-relational mapping ). A ser o caso, acredito que importa mudar a descrição até para que mais pessoas consigam encontrar esta lib.

Separação de conceitos

Olá,
Pela descrição desta lib, notei que provavelmente trata-se de um Adapter e não um ORM(Object-relational mapping ). A ser o caso, acredito que importa mudar a descrição até para que mais pessoas consigam encontrar esta lib.

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.