Skip to content

Commit

Permalink
docs: add ProducibleMessage/ConsumableMessage/MessageEnvelope
Browse files Browse the repository at this point in the history
  • Loading branch information
weyoss committed Dec 17, 2023
1 parent 2961a22 commit 55aa68e
Show file tree
Hide file tree
Showing 26 changed files with 993 additions and 1,195 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ RedisSMQ is a Node.js library for queuing messages (aka jobs) and processing the

* [High-performance message processing](docs/performance.md).
* Flexible Producer/Consumer model which offers [Multi-Queue Producers](docs/producing-messages.md) & [Multi-Queue Consumers](docs/consuming-messages.md), focuses on simplicity and without tons of features. This makes RedisSMQ an ideal message broker for microservices-based applications.
* In case of failures, while delivering or processing a message, RedisSMQ can guaranty that the message is not lost and that it is redelivered [at-least-once](docs/api/classes/MessageEnvelope.md#setretrythreshold). When configured to do so, RedisSMQ can also ensure that the message is delivered [at-most-once](docs/api/classes/MessageEnvelope.md#setretrythreshold).
* In case of failures, while delivering or processing a message, RedisSMQ can guaranty that the message is not lost and that it is redelivered [at-least-once](docs/api/classes/ProducibleMessage.md#setretrythreshold). When configured to do so, RedisSMQ can also ensure that the message is delivered [at-most-once](docs/api/classes/ProducibleMessage.md#setretrythreshold).
* RedisSMQ offers different exchange types: [Direct Exchange](docs/message-exchanges.md#direct-exchange), [Topic Exchange](docs/message-exchanges.md#topic-exchange), and [FanOut Exchange](docs/message-exchanges.md#fanout-exchange) for publishing a message to one or multiple queues.
* 3 queuing strategies that you may use depending on your needs and requirements: [FIFO queues, LIFO queues, and Reliable Priority Queues](docs/queues.md).
* A message can be [set to expire](docs/api/classes/MessageEnvelope.md#setttl) if it has not been delivered within a given amount of time. [Consumption timeout](docs/api/classes/MessageEnvelope.md#setconsumetimeout) allows canceling a message consumption if a consumer did not acknowledge the message for a period of time.
* A message can be [set to expire](docs/api/classes/ProducibleMessage.md#setttl) if it has not been delivered within a given amount of time. [Consumption timeout](docs/api/classes/ProducibleMessage.md#setconsumetimeout) allows canceling a message consumption if a consumer did not acknowledge the message for a period of time.
* [Queue Rate Limiting](docs/queue-rate-limiting.md) which allows to control the rate at which the messages are consumed from a given queue.
* Builtin [message scheduler](docs/scheduling-messages.md) allowing to delay a message, to deliver a message for N times with an optional period between deliveries, or simply to schedule message delivery using CRON expressions.
* [Multiplexing](/docs/multiplexing.md): A feature which allows message handlers to use a single redis connection to dequeue and consume messages.
Expand Down Expand Up @@ -56,7 +56,7 @@ Considerations:

## Usage

RedisSMQ provides 3 classes in order to work with the message queue: `MessageEnvelope`, `Producer`, and `Consumer`.
RedisSMQ provides 3 classes in order to work with the message queue: `ProducibleMessage`, `Producer`, and `Consumer`.

Producers and consumers exchange data using one or multiple queues that may be created using the [Queue Class](docs/api/classes/Queue.md).

Expand All @@ -76,11 +76,11 @@ queue.save('my_queue', EQueueType.LIFO_QUEUE, (err) => console.log(err));
### Producing a message

```javascript
const { Producer, MessageEnvelope } = require('redis-smq');
const { Producer, ProducibleMessage } = require('redis-smq');

const producer = new Producer();

const msg = new MessageEnvelope();
const msg = new ProducibleMessage();
msg.setQueue('my_queue').setBody('Hello Word!')

producer.produce(msg, (err) => console.log(err));
Expand Down
113 changes: 53 additions & 60 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
- [ExchangeFanOut](classes/ExchangeFanOut.md)
- [ExchangeTopic](classes/ExchangeTopic.md)
- [Message](classes/Message.md)
- [MessageEnvelope](classes/MessageEnvelope.md)
- [Namespace](classes/Namespace.md)
- [Producer](classes/Producer.md)
- [ProducibleMessage](classes/ProducibleMessage.md)
- [Queue](classes/Queue.md)
- [QueueAcknowledgedMessages](classes/QueueAcknowledgedMessages.md)
- [QueueDeadLetteredMessages](classes/QueueDeadLetteredMessages.md)
Expand All @@ -38,31 +38,31 @@

- [ConsumerError](classes/ConsumerError.md)
- [ConsumerMessageHandlerAlreadyExistsError](classes/ConsumerMessageHandlerAlreadyExistsError.md)
- [ExchangeError](classes/ExchangeError.md)
- [ExchangeFanOutError](classes/ExchangeFanOutError.md)
- [ExchangeInvalidDataError](classes/ExchangeInvalidDataError.md)
- [ExchangeError](classes/ExchangeError.md)
- [MessageDeleteError](classes/MessageDeleteError.md)
- [MessageNotFoundError](classes/MessageNotFoundError.md)
- [MessageDestinationQueueAlreadySetError](classes/MessageDestinationQueueAlreadySetError.md)
- [MessageDestinationQueueRequiredError](classes/MessageDestinationQueueRequiredError.md)
- [MessageError](classes/MessageError.md)
- [MessageExchangeRequiredError](classes/MessageExchangeRequiredError.md)
- [MessageNotFoundError](classes/MessageNotFoundError.md)
- [ProducerError](classes/ProducerError.md)
- [ProducerInstanceNotRunningError](classes/ProducerInstanceNotRunningError.md)
- [ProducerMessageAlreadyPublishedError](classes/ProducerMessageAlreadyPublishedError.md)
- [ProducerMessageNotPublishedError](classes/ProducerMessageNotPublishedError.md)
- [ProducerMessageNotScheduledError](classes/ProducerMessageNotScheduledError.md)
- [QueueRateLimitError](classes/QueueRateLimitError.md)
- [QueueNamespaceNotFoundError](classes/QueueNamespaceNotFoundError.md)
- [QueueNotEmptyError](classes/QueueNotEmptyError.md)
- [QueueNotFoundError](classes/QueueNotFoundError.md)
- [QueueError](classes/QueueError.md)
- [QueueExistsError](classes/QueueExistsError.md)
- [QueueHasRunningConsumersError](classes/QueueHasRunningConsumersError.md)
- [QueueMessageRequeueError](classes/QueueMessageRequeueError.md)
- [QueueNamespaceNotFoundError](classes/QueueNamespaceNotFoundError.md)
- [QueueNotEmptyError](classes/QueueNotEmptyError.md)
- [QueueNotFoundError](classes/QueueNotFoundError.md)
- [QueueRateLimitError](classes/QueueRateLimitError.md)

### Interfaces

- [IConsumableMessage](interfaces/IConsumableMessage.md)
- [IConsumerHeartbeat](interfaces/IConsumerHeartbeat.md)
- [IConsumerHeartbeatPayload](interfaces/IConsumerHeartbeatPayload.md)
- [IConsumerMessageHandlerArgs](interfaces/IConsumerMessageHandlerArgs.md)
Expand Down Expand Up @@ -119,163 +119,158 @@

Ƭ **IEventListenersConfigRequired**: `Required`\<[`IEventListenersConfig`](interfaces/IEventListenersConfig.md)\>

---
___

### IQueueMessagesPageParams

Ƭ **IQueueMessagesPageParams**: `Object`

#### Type declaration


| Name | Type |
| :-------------- | :--------- |
| Name | Type |
| :------ | :------ |
| `currentPage` | `number` |
| `offsetEnd` | `number` |
| `offsetEnd` | `number` |
| `offsetStart` | `number` |
| `totalPages` | `number` |
| `totalPages` | `number` |

---
___

### TConsumerMessageHandler

Ƭ **TConsumerMessageHandler**: (`msg`: [`MessageEnvelope`](classes/Message.md), `cb`: `ICallback`\<`void`\>) => `void`
Ƭ **TConsumerMessageHandler**: (`msg`: [`IConsumableMessage`](interfaces/IConsumableMessage.md), `cb`: `ICallback`\<`void`\>) => `void`

#### Type declaration

▸ (`msg`, `cb`): `void`

##### Parameters


| Name | Type |
| :------ | :-------------------------------- |
| `msg` | [`MessageEnvelope`](classes/Message.md) |
| `cb` | `ICallback`\<`void`\> |
| Name | Type |
| :------ | :------ |
| `msg` | [`IConsumableMessage`](interfaces/IConsumableMessage.md) |
| `cb` | `ICallback`\<`void`\> |

##### Returns

`void`

---
___

### TConsumerRedisKeys

Ƭ **TConsumerRedisKeys**: `ReturnType`\<typeof `redisKeys`[``"getConsumerKeys"``]\>

---
___

### TEventListenerInitArgs

Ƭ **TEventListenerInitArgs**: `Object`

#### Type declaration


| Name | Type |
| :---------------- | :--------------------------------------------------------------- |
| Name | Type |
| :------ | :------ |
| `eventProvider` | `EventEmitter`\<[`TRedisSMQEvent`](README.md#tredissmqevent)\> |
| `instanceId` | `string` |
| `instanceId` | `string` |

---
___

### TExchange

Ƭ **TExchange**: [`TExchangeDirect`](README.md#texchangedirect) \| [`TExchangeTopic`](README.md#texchangetopic) \| [`TExchangeFanOut`](README.md#texchangefanout)

---
___

### TExchangeDirect

Ƭ **TExchangeDirect**: [`IExchange`](interfaces/IExchange.md)\<[`TExchangeDirectBindingParams`](README.md#texchangedirectbindingparams), [`DIRECT`](enums/EExchangeType.md#direct)\>

---
___

### TExchangeDirectBindingParams

Ƭ **TExchangeDirectBindingParams**: [`IQueueParams`](interfaces/IQueueParams.md) \| `string`

---
___

### TExchangeDirectSerialized

Ƭ **TExchangeDirectSerialized**: [`IExchangeSerialized`](interfaces/IExchangeSerialized.md)\<[`TExchangeDirectBindingParams`](README.md#texchangedirectbindingparams), [`DIRECT`](enums/EExchangeType.md#direct)\>

---
___

### TExchangeFanOut

Ƭ **TExchangeFanOut**: [`IExchange`](interfaces/IExchange.md)\<[`TExchangeFanOutBindingParams`](README.md#texchangefanoutbindingparams), [`FANOUT`](enums/EExchangeType.md#fanout)\>

---
___

### TExchangeFanOutBindingParams

Ƭ **TExchangeFanOutBindingParams**: `string`

---
___

### TExchangeFanOutSerialized

Ƭ **TExchangeFanOutSerialized**: [`IExchangeSerialized`](interfaces/IExchangeSerialized.md)\<[`TExchangeFanOutBindingParams`](README.md#texchangefanoutbindingparams), [`FANOUT`](enums/EExchangeType.md#fanout)\>

---
___

### TExchangeSerialized

Ƭ **TExchangeSerialized**: [`TExchangeDirectSerialized`](README.md#texchangedirectserialized) \| [`TExchangeTopicSerialized`](README.md#texchangetopicserialized) \| [`TExchangeFanOutSerialized`](README.md#texchangefanoutserialized)

---
___

### TExchangeTopic

Ƭ **TExchangeTopic**: [`IExchange`](interfaces/IExchange.md)\<[`TExchangeTopicBindingParams`](README.md#texchangetopicbindingparams), [`TOPIC`](enums/EExchangeType.md#topic)\>

---
___

### TExchangeTopicBindingParams

Ƭ **TExchangeTopicBindingParams**: [`TTopicParams`](README.md#ttopicparams) \| `string`

---
___

### TExchangeTopicSerialized

Ƭ **TExchangeTopicSerialized**: [`IExchangeSerialized`](interfaces/IExchangeSerialized.md)\<[`TExchangeTopicBindingParams`](README.md#texchangetopicbindingparams), [`TOPIC`](enums/EExchangeType.md#topic)\>

---
___

### TMessageConsumeOptions

Ƭ **TMessageConsumeOptions**: `Object`

#### Type declaration


| Name | Type |
| :----------------- | :--------- |
| Name | Type |
| :------ | :------ |
| `consumeTimeout` | `number` |
| `retryDelay` | `number` |
| `retryDelay` | `number` |
| `retryThreshold` | `number` |
| `ttl` | `number` |
| `ttl` | `number` |

---
___

### TQueueConsumer

Ƭ **TQueueConsumer**: `Object`

#### Type declaration


| Name | Type |
| :------------ | :----------- |
| `createdAt` | `number` |
| `hostname` | `string` |
| Name | Type |
| :------ | :------ |
| `createdAt` | `number` |
| `hostname` | `string` |
| `ipAddress` | `string`[] |
| `pid` | `number` |
| `pid` | `number` |

---
___

### TRedisSMQEvent

Expand All @@ -297,18 +292,17 @@
| `messageRequeued` | (`messageId`: `string`, `queue`: [`IQueueParams`](interfaces/IQueueParams.md), `messageHandlerId`: `string`, `consumerId`: `string`) => `void` ; |
| `messageUnacknowledged` | (`cause`: [`EConsumeMessageUnacknowledgedCause`](enums/EConsumeMessageUnacknowledgedCause.md), `messageId`: `string`, `queue`: [`IQueueParams`](interfaces/IQueueParams.md), `messageHandlerId`: `string`, `consumerId`: `string`) => `void` ; |

---
___

### TTopicParams

Ƭ **TTopicParams**: `Object`

#### Type declaration


| Name | Type |
| :-------- | :--------- |
| `ns` | `string` |
| Name | Type |
| :------ | :------ |
| `ns` | `string` |
| `topic` | `string` |

## Functions
Expand All @@ -319,9 +313,8 @@

#### Parameters


| Name | Type |
| :----- | :---------------------- |
| Name | Type |
| :------ | :------ |
| `cb` | `ICallback`\<`void`\> |

#### Returns
Expand Down
Loading

0 comments on commit 55aa68e

Please sign in to comment.