From 83ce680d4ba06901d4b524c542036d8f661a8af4 Mon Sep 17 00:00:00 2001 From: Weyoss Date: Tue, 21 Nov 2023 23:01:34 +0100 Subject: [PATCH] docs: update configuration.md --- docs/api/interfaces/IRedisSMQConfig.md | 4 +-- docs/configuration.md | 49 ++++++++++++++++++++------ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/docs/api/interfaces/IRedisSMQConfig.md b/docs/api/interfaces/IRedisSMQConfig.md index 2115ef04..245ae7ab 100644 --- a/docs/api/interfaces/IRedisSMQConfig.md +++ b/docs/api/interfaces/IRedisSMQConfig.md @@ -21,7 +21,7 @@ ### logger -> **logger**?: `ILoggerConfig` +> **logger**?: [`ILoggerConfig`](https://github.com/weyoss/redis-smq-common/blob/master/docs/api/interfaces/ILoggerConfig.md) *** @@ -39,5 +39,5 @@ ### redis -> **redis**?: `IRedisConfig` +> **redis**?: [`IRedisConfig`](https://github.com/weyoss/redis-smq-common/blob/master/docs/api/README.md#iredisconfig) diff --git a/docs/configuration.md b/docs/configuration.md index dc6539b3..3fbb2c84 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1,22 +1,45 @@ ->[RedisSMQ](../README.md) / [Docs](README.md) / Configuration - +> [RedisSMQ](../README.md) / [Docs](README.md) / Configuration # Configuration -You can configure many of RedisSMQ features using a config object that you can pass in to a configurable component (for example a Consumer constructor). +RedisSMQ configuration is a one-time setup that takes place, usually, during your application initialization and before +using any exported class or function from the library. + +To register a configuration object RedisSMQ provides a singleton class that may be used as shown bellow: + +```javascript +'use strict'; +const { Configuration, ERedisConfigClient } = require('redis-smq'); + +const config = { + redis: { + client: ERedisConfigClient.IOREDIS, + options: { + host: '127.0.0.1', + port: 6379, + }, + }, +} + +Configuration.getSetConfig(config); +``` + +See [Configuration Class Reference](api/classes/Configuration.md) for more details. ## Configuration parameters +See [IRedisSMQConfig Interface](api/interfaces/IRedisSMQConfig.md) for more details. + **Configuration Example** ```javascript 'use strict'; -const path = require('path'); +const { ERedisConfigClient } = require('redis-smq'); module.exports = { namespace: 'my_project_name', redis: { - client: 'redis', + client: ERedisConfigClient.IOREDIS, options: { host: '127.0.0.1', port: 6379, @@ -39,14 +62,20 @@ module.exports = { messages: { store: false, }, - }; ``` -**Parameters** +#### Message Storage + +Published messages, to a queue, are permanently stored unless deleted explicitly. + +The `message.store` option allows, additionally, to configure acknowledged/dead-lettered messages storage for all message queues. + +In other words, when `message.store` is enabled, a queue, in addition to all published messages, may hold a list of all +dead-lettered messages for example. + +By default acknowledged and dead-lettered messages are not stored. -See [IRedisSMQConfig Interface](api/interfaces/IRedisSMQConfig.md) for more details. - **messages.store Usage Examples** - Only storing dead-lettered messages: @@ -93,4 +122,4 @@ const config = { } } } -``` \ No newline at end of file +```