<commit_before># Microservice Utils

Contains rabbitmq-based transport for establishing a net of loosely coupled microservices with a simple rpc-style
calling interface.

## Install

`npm i ms-utils -S`

Heavily relies on `dropbox/amqp-coffee` lib for establishing communication to rabbitmq.

## Usage

```js
const AMQPTransport = require('ms-utils');

const amqp = new AMQPTransport(config);

amqp.connect().then((amqpInstance) => {
  // amqp === amqpInstance
  // we are connected, do things here
});
```

In a more generic case, you want to use `.connect(config, messageHandler)` helper, which would create queues and bind them to exchanges for you
based on the provided configuration.
Consider the following example:

```js
const AMQPTransport = require('ms-utils');

// message routers
function router(message, headers, actions, next) {
  switch (headers.routingKey) {
    case 'very.important.route':
      // examine message, do smth with it, reply with next callback
      return next(null, 'delivered!');
  }
}

AMQPTransport.connect(configuration, router).then(function (amqp) {
  // amqp instance
  // you can use it do directly send messages
  // amqp.publish
  // amqp.publishAndWait
  // amqp.send
  // amqp.sendAndWait
  //
  // This all internally uses [amqp-coffee publish method](https://github.com/dropbox/amqp-coffee#connectionpublishexchange-routingkey-data-publishoptions-callback)
  // If message fails - it will be rejected in a promise
});
```
<commit_msg>Update readme with proper package name<commit_after># Microservice Utils

Contains rabbitmq-based transport for establishing a net of loosely coupled microservices with a simple rpc-style
calling interface.

## Install

`npm i ms-amqp-transport -S`

Heavily relies on `dropbox/amqp-coffee` lib for establishing communication to rabbitmq.

## Usage

```js
const AMQPTransport = require('ms-amqp-transport');

const amqp = new AMQPTransport(config);

amqp.connect().then((amqpInstance) => {
  // amqp === amqpInstance
  // we are connected, do things here
});
```

In a more generic case, you want to use `.connect(config, messageHandler)` helper, which would create queues and bind them to exchanges for you
based on the provided configuration.
Consider the following example:

```js
const AMQPTransport = require('ms-amqp-transport');

// message routers
function router(message, headers, actions, next) {
  switch (headers.routingKey) {
    case 'very.important.route':
      // examine message, do smth with it, reply with next callback
      return next(null, 'delivered!');
  }
}

AMQPTransport.connect(configuration, router).then(function (amqp) {
  // amqp instance
  // you can use it do directly send messages
  // amqp.publish
  // amqp.publishAndWait
  // amqp.send
  // amqp.sendAndWait
  //
  // This all internally uses [amqp-coffee publish method](https://github.com/dropbox/amqp-coffee#connectionpublishexchange-routingkey-data-publishoptions-callback)
  // If message fails - it will be rejected in a promise
});
```

{'fraction_non_alphanumeric': 0.10915726609157266, 'fraction_numerical': 0.0, 'mean_word_length': 4.067226890756302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5944497', 'n_tokens_mistral': 918, 'n_tokens_neox': 875, 'n_words': 299}