0.3.0 • Published 2 years ago

brokher v0.3.0

Weekly downloads
26
License
MIT
Repository
-
Last release
2 years ago

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

0.3.0

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.3

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.2.2

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3-beta.2

3 years ago

0.1.3-beta.1

3 years ago

0.1.3-beta

3 years ago

0.1.3-beta.3

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago