Skip to content

Commit

Permalink
docs(api): update API documentation and references
Browse files Browse the repository at this point in the history
- Rename EventBusRedisInstance class to EventBus
- Modify examples and FAQs to use new EventBus name
- Remove redundant RedisInstance from class name
  • Loading branch information
weyoss committed Feb 14, 2025
1 parent f9dca11 commit 08f85ae
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 110 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ A High-Performance Redis Simple Message Queue for Node.js

**Key Features**

* [High-performance message processing](docs/performance.md)
* [Flexible producer/consumer model with multi-queue producers and consumers](docs/consuming-messages.md)
* [Different exchange types (Direct, Topic, FanOut) for publishing messages to one or multiple queues](docs/message-exchanges.md)
* [Two delivery models (Point-2-Point and Pub/Sub)](docs/queue-delivery-models.md) with reliable delivery and configurable retry modes
* [Three queuing strategies (FIFO, LIFO, Priority Queues)](docs/queues.md)
* [Message handler worker threads for sandboxing and performance improvement](docs/message-handler-worker-threads.md)
* [Message expiration and consumption timeout](docs/messages.md)
* [Queue rate limiting for controlling message consumption rates](docs/queue-rate-limiting.md)
* [Built-in scheduler for delayed message delivery and repeating messages](docs/scheduling-messages.md)
* [RESTful API](docs/redis-smq-rest-api.md) and [Web UI](docs/redis-smq-web-ui.md) for interacting with the message queue
* [Support for ESM and CJS modules](docs/esm-cjs-modules.md)
- 🚀 [High-performance message processing](docs/performance.md)
- 🔄 [Flexible producer/consumer model with multi-queue producers and consumers](docs/consuming-messages.md)
- 🔀 [Different exchange types (Direct, Topic, FanOut) for publishing messages to one or multiple queues](docs/message-exchanges.md)
- 📬 [Two delivery models (Point-2-Point and Pub/Sub)](docs/queue-delivery-models.md) with reliable delivery and configurable retry modes
- 📊 [Three queuing strategies (FIFO, LIFO, Priority Queues)](docs/queues.md)
- 🧵 [Message handler worker threads for sandboxing and performance improvement](docs/message-handler-worker-threads.md)
- ⏱️ [Message expiration and consumption timeout](docs/messages.md)
- 🚦 [Queue rate limiting for controlling message consumption rates](docs/queue-rate-limiting.md)
- 🕰️ [Built-in scheduler for delayed message delivery and repeating messages](docs/scheduling-messages.md)
- 🌐 [RESTful API](docs/redis-smq-rest-api.md) and [Web UI](docs/redis-smq-web-ui.md) for interacting with the message queue
- 📦 [Support for ESM and CJS modules](docs/esm-cjs-modules.md)

**Use Cases**

Expand All @@ -35,7 +35,17 @@ To get started with RedisSMQ, you can install the library using npm:
```bash
npm i redis-smq@rc
```
Create a queue, produce a message, and consume it using the provided classes and methods:

Don't forget to install a Redis client. Choose either node-redis or ioredis.

```shell
npm install @redis/client
# or
npm install ioredis
```

Here's a basic example to create a queue, produce a message, and consume it:

```javascript
// Creating a queue
const queue = new Queue();
Expand Down
2 changes: 1 addition & 1 deletion docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- [Configuration](classes/Configuration.md)
- [Consumer](classes/Consumer.md)
- [ConsumerGroups](classes/ConsumerGroups.md)
- [EventBusRedisInstance](classes/EventBusRedisInstance.md)
- [EventBus](classes/EventBus.md)
- [ExchangeDirect](classes/ExchangeDirect.md)
- [ExchangeFanOut](classes/ExchangeFanOut.md)
- [ExchangeTopic](classes/ExchangeTopic.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
[RedisSMQ](../../../README.md) / [Docs](../../README.md) / [API Reference](../README.md) / EventBusRedisInstance
[RedisSMQ](../../../README.md) / [Docs](../../README.md) / [API Reference](../README.md) / EventBus

# Class: EventBusRedisInstance
# Class: EventBus

## Hierarchy

- `EventEmitter`\<`Pick`\<`TRedisClientEvent`, ``"error"``\>\>

**`EventBusRedisInstance`**
**`EventBus`**

## Table of contents

### Constructors

- [constructor](EventBusRedisInstance.md#constructor)
- [constructor](EventBus.md#constructor)

### Methods

- [emit](EventBusRedisInstance.md#emit)
- [getInstance](EventBusRedisInstance.md#getinstance)
- [getSetInstance](EventBusRedisInstance.md#getsetinstance)
- [init](EventBusRedisInstance.md#init)
- [on](EventBusRedisInstance.md#on)
- [once](EventBusRedisInstance.md#once)
- [removeAllListeners](EventBusRedisInstance.md#removealllisteners)
- [removeListener](EventBusRedisInstance.md#removelistener)
- [shutdown](EventBusRedisInstance.md#shutdown)
- [emit](EventBus.md#emit)
- [getInstance](EventBus.md#getinstance)
- [getSetInstance](EventBus.md#getsetinstance)
- [init](EventBus.md#init)
- [on](EventBus.md#on)
- [once](EventBus.md#once)
- [removeAllListeners](EventBus.md#removealllisteners)
- [removeListener](EventBus.md#removelistener)
- [shutdown](EventBus.md#shutdown)

## Constructors

### constructor

**new EventBusRedisInstance**(): [`EventBusRedisInstance`](EventBusRedisInstance.md)
**new EventBus**(): [`EventBus`](EventBus.md)

#### Returns

[`EventBusRedisInstance`](EventBusRedisInstance.md)
[`EventBus`](EventBus.md)

#### Inherited from

EventEmitter\<
Pick\<TRedisClientEvent, 'error'\>
\>.constructor
EventEmitter\<Pick\<TRedisClientEvent, 'error'\>\>.constructor

## Methods

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/Message.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Class: Message

The Message class provides methods for interacting with Redis-SMQ messages.
It utilizes the RedisClientInstance to perform operations on Redis.
It utilizes the RedisClient to perform operations on Redis.

## Table of contents

Expand Down
19 changes: 9 additions & 10 deletions docs/event-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The RedisSMQ EventBus enables your applications to subscribe to various system e
By default, most events in RedisSMQ are not published to the EventBus. To utilize the EventBus, you must first enable
it in your [RedisSMQ Configuration](configuration.md).

For detailed information, refer to the [EventBusRedisInstance API](api/classes/EventBusRedisInstance.md).
For detailed information, refer to the [EventBus API](api/classes/EventBus.md).

## Supported EventBus Events

Expand Down Expand Up @@ -48,9 +48,9 @@ For more details on configuration, see [RedisSMQ Configuration](configuration.md
To create an instance of the EventBus, use the following code:

```typescript
import { EventBusRedisInstance } from 'redis-smq';
import { EventBus } from 'redis-smq';

EventBusRedisInstance.getSetInstance((err, eventBus) => {
EventBus.getSetInstance((err, eventBus) => {
if (err) {
console.error('Failed to create EventBus instance:', err);
} else {
Expand All @@ -75,14 +75,13 @@ eventBus.on('consumer.consumeMessage.messageAcknowledged', (messageId, queue, me

To properly shut down the EventBus instance, call the shutDown method:


```javascript
EventBusRedisInstance.shutDown((err) => {
if (err) {
console.error('Error shutting down EventBus:', err);
} else {
console.log('EventBus shut down successfully');
}
EventBus.shutDown((err) => {
if (err) {
console.error('Error shutting down EventBus:', err);
} else {
console.log('EventBus shut down successfully');
}
});
```

Expand Down
2 changes: 1 addition & 1 deletion docs/faqs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Frequently Asked Questions

- [What are the key features of RedisSMQ and how do they differ from other messaging libraries?](./comparing-redissmq-to-other-libraries)
- [What are the key features of RedisSMQ and how do they differ from other messaging libraries?](./comparing-redissmq-to-other-libraries.md)
- [What is the recommended way to set up and configure RedisSMQ for a new project?](./getting-started.md)
- [How do I handle errors and exceptions when using RedisSMQ\'s classes and methods?](./handling-errors-and-exceptions.md)
- [What are the most important features and changes that RedisSMQ v8 introduces?](./release-v8-changes.md)
41 changes: 25 additions & 16 deletions docs/faqs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@
- **Node.js**: Make sure you have Node.js >= v18 installed on your system.

2. Install RedisSMQ

First, install the package using npm:

```bash
npm install redis-smq@rc
```

3. Install a Redis client:

3. Create a configuration file:
Choose either node-redis or ioredis. For this example, we'll use ioredis:

```shell
npm install ioredis
```

Create a new file, for example, `redis-smq-config.js`, and add the following basic configuration:

**File: /path/to/your/project/redis-smq-config.js**
4. Create a configuration file:

Create a new file, for example, `redis-smq-config.js`, and add the following basic configuration:

File: /path/to/your/project/redis-smq-config.js
```javascript
import { ERedisConfigClient } from 'redis-smq-common';

Expand All @@ -40,9 +49,9 @@
};
```

4. Create a queue

**File: /path/to/your/project/queue.js**
5. Create a queue
File: /path/to/your/project/queue.js
```javascript
import { Queue, Configuration } from 'redis-smq';
import config from './path/to/your/project/redis-smq-config.js';
Expand All @@ -65,11 +74,11 @@
});
```

5. Create a producer

6. Create a producer
Create a file for your producer, e.g., `producer.js`:

**File: /path/to/your/project/producer.js**
File: /path/to/your/project/producer.js
```javascript
import { Producer, ProducibleMessage, Configuration } from 'redis-smq';
import config from './path/to/your/project/redis-smq-config.js';
Expand Down Expand Up @@ -101,11 +110,11 @@
});
```

6. Create a consumer

7. Create a consumer
Create a file for your consumer, e.g., `consumer.js`:

**File: /path/to/your/project/consumer.js**
File: /path/to/your/project/consumer.js
```javascript
import { Consumer, Configuration } from 'redis-smq';
import config from './path/to/your/project/redis-smq-config.js';
Expand All @@ -130,7 +139,7 @@
});
```

7. Run your application
8. Run your application

You can now run your producer and consumer in separate terminal windows:

Expand Down
2 changes: 1 addition & 1 deletion docs/graceful-shutdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Before terminating your application, be sure to call `shutdown()` on the followi

- [Consumer](api/classes/Consumer.md)
- [ConsumerGroups](api/classes/ConsumerGroups.md)
- [EventBusRedisInstance](api/classes/EventBusRedisInstance.md)
- [EventBus](api/classes/EventBus.md)
- [ExchangeDirect](api/classes/ExchangeDirect.md)
- [ExchangeFanOut](api/classes/ExchangeFanOut.md)
- [ExchangeTopic](api/classes/ExchangeTopic.md)
Expand Down
8 changes: 0 additions & 8 deletions examples/javascript/using-async-await.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ const config = {
},
logger: {
enabled: true,
options: {
level: 'info',
// streams: [
// {
// path: path.normalize(`${__dirname}/logs/redis-smq.log`),
// },
// ],
},
},
};

Expand Down
10 changes: 1 addition & 9 deletions examples/javascript/using-async-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* in the root directory of this source tree.
*/

import { ERedisConfigClient, logger } from 'redis-smq-common';
import bluebird from 'bluebird';
import {
Configuration,
Expand All @@ -18,6 +17,7 @@ import {
ProducibleMessage,
Queue,
} from 'redis-smq';
import { ERedisConfigClient, logger } from 'redis-smq-common';

const { promisifyAll } = bluebird;

Expand All @@ -32,14 +32,6 @@ const config = {
},
logger: {
enabled: true,
options: {
level: 'info',
// streams: [
// {
// path: path.normalize(`${__dirname}/logs/redis-smq.log`),
// },
// ],
},
},
};

Expand Down
8 changes: 0 additions & 8 deletions examples/javascript/using-callbacks.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ const config = {
},
logger: {
enabled: true,
options: {
level: 'info',
// streams: [
// {
// path: path.normalize(`${__dirname}/logs/redis-smq.log`),
// },
// ],
},
},
};

Expand Down
10 changes: 1 addition & 9 deletions examples/javascript/using-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* in the root directory of this source tree.
*/

import { ERedisConfigClient, logger } from 'redis-smq-common';
import {
Configuration,
Consumer,
Expand All @@ -17,6 +16,7 @@ import {
ProducibleMessage,
Queue,
} from 'redis-smq';
import { ERedisConfigClient, logger } from 'redis-smq-common';

const config = {
namespace: 'ns1',
Expand All @@ -29,14 +29,6 @@ const config = {
},
logger: {
enabled: true,
options: {
level: 'info',
// streams: [
// {
// path: path.normalize(`${__dirname}/logs/redis-smq.log`),
// },
// ],
},
},
};

Expand Down
8 changes: 0 additions & 8 deletions examples/typescript/using-async-await.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ export const config: IRedisSMQConfig = {
},
logger: {
enabled: true,
options: {
level: 'info',
// streams: [
// {
// path: path.normalize(`${__dirname}/logs/redis-smq.log`),
// },
// ],
},
},
};

Expand Down
8 changes: 0 additions & 8 deletions examples/typescript/using-callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ export const config: IRedisSMQConfig = {
},
logger: {
enabled: true,
options: {
level: 'info',
// streams: [
// {
// path: path.normalize(`${__dirname}/logs/redis-smq.log`),
// },
// ],
},
},
};

Expand Down

0 comments on commit 08f85ae

Please sign in to comment.