Skip to content

Commit b525567

Browse files
committed
docs(redis-smq): streamline and standardize JSDoc documentation
1 parent 2abaaab commit b525567

File tree

112 files changed

+4484
-17048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+4484
-17048
lines changed

packages/redis-smq/docs/api/classes/ConfigManager.md

Lines changed: 45 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,19 @@
22

33
# Class: ConfigManager
44

5-
Manages RedisSMQ configuration operations including retrieval, updates, and reloads.
6-
Provides a high-level interface for interacting with the configuration system,
7-
handling validation, persistence, and cross-instance synchronization.
5+
Manages RedisSMQ configuration operations.
86

9-
This class works in conjunction with Configuration (low-level persistence) and
10-
ConfigSync (cross-instance synchronization) to provide a complete configuration
11-
management solution.
7+
Provides methods to get, update, and reload configuration,
8+
with validation and cross-instance synchronization.
129

1310
## Example
1411

15-
```typescript
16-
// Get current configuration
12+
```ts
1713
const config = ConfigManager.getConfig();
1814

19-
// Update configuration
2015
await configManager.updateConfig({ messageAudit: true });
2116

22-
// Reload configuration from Redis
23-
await configManager.reload();
17+
const newConfig = await configManager.reload();
2418
```
2519

2620
## Constructors
@@ -40,23 +34,18 @@ await configManager.reload();
4034
> **getConfig**(): [`IRedisSMQParsedConfig`](../interfaces/IRedisSMQParsedConfig.md)
4135
4236
Gets the current parsed configuration object.
43-
This method returns a frozen copy of the configuration to prevent
44-
accidental modifications. All configuration properties are fully parsed
45-
and validated.
4637

4738
#### Returns
4839

4940
[`IRedisSMQParsedConfig`](../interfaces/IRedisSMQParsedConfig.md)
5041

51-
The current parsed configuration object (read-only)
42+
Read-only parsed configuration
5243

5344
#### Example
5445

55-
```typescript
46+
```ts
5647
const config = configManager.getConfig();
57-
58-
// The returned object is frozen and cannot be modified
59-
// config.namespace = 'new-ns'; // This will fail in strict mode
48+
console.log(config.namespace);
6049
```
6150

6251
---
@@ -66,20 +55,18 @@ const config = configManager.getConfig();
6655
> **getConfigVersion**(): `number`
6756
6857
Gets the current configuration version number.
69-
The version number increments with each successful configuration update
70-
and is used for optimistic locking to prevent concurrent modification conflicts.
7158

7259
#### Returns
7360

7461
`number`
7562

76-
The current configuration version number
63+
Version number (increments on each update)
7764

7865
#### Example
7966

80-
```typescript
67+
```ts
8168
const version = configManager.getConfigVersion();
82-
console.log(`Configuration version: ${version}`);
69+
console.log(version);
8370
```
8471

8572
---
@@ -90,69 +77,57 @@ console.log(`Configuration version: ${version}`);
9077

9178
> **reload**(): `Promise`\<[`IRedisSMQParsedConfig`](../interfaces/IRedisSMQParsedConfig.md)\>
9279
93-
Reloads the configuration from Redis storage.
94-
This method fetches the latest configuration from Redis and updates the
95-
internal configuration state. Useful when manual refresh is needed or when
96-
recovering from certain error conditions.
80+
Reloads configuration from Redis storage.
9781

9882
##### Returns
9983

10084
`Promise`\<[`IRedisSMQParsedConfig`](../interfaces/IRedisSMQParsedConfig.md)\>
10185

102-
Promise with the reloaded configuration if callback not provided
86+
Promise if no callback, otherwise void
10387

10488
##### Example
10589

106-
```typescript
107-
// Using async/await
90+
```ts
91+
// Promise
10892
const config = await configManager.reload();
10993

110-
// Using callback
94+
// Callback
11195
configManager.reload((err, config) => {
112-
if (err) {
113-
console.error('Failed to reload config:', err);
114-
return;
115-
}
116-
console.log('Config reloaded:', config);
96+
if (err) throw err;
97+
console.log(config);
11798
});
11899
```
119100

120101
#### Call Signature
121102

122103
> **reload**(`cb`): `void`
123104
124-
Reloads the configuration from Redis storage.
125-
This method fetches the latest configuration from Redis and updates the
126-
internal configuration state. Useful when manual refresh is needed or when
127-
recovering from certain error conditions.
105+
Reloads configuration from Redis storage.
128106

129107
##### Parameters
130108

131109
###### cb
132110

133111
`ICallback`\<[`IRedisSMQParsedConfig`](../interfaces/IRedisSMQParsedConfig.md)\>
134112

135-
Optional callback function for error-first pattern
113+
(err, config) => void. Returns IRedisSMQParsedConfig
136114

137115
##### Returns
138116

139117
`void`
140118

141-
Promise with the reloaded configuration if callback not provided
119+
Promise if no callback, otherwise void
142120

143121
##### Example
144122

145-
```typescript
146-
// Using async/await
123+
```ts
124+
// Promise
147125
const config = await configManager.reload();
148126

149-
// Using callback
127+
// Callback
150128
configManager.reload((err, config) => {
151-
if (err) {
152-
console.error('Failed to reload config:', err);
153-
return;
154-
}
155-
console.log('Config reloaded:', config);
129+
if (err) throw err;
130+
console.log(config);
156131
});
157132
```
158133

@@ -164,104 +139,68 @@ configManager.reload((err, config) => {
164139

165140
> **updateConfig**(`updates`): `Promise`\<`void`\>
166141
167-
Updates the configuration with the provided changes.
168-
This method merges the updates with the current configuration, validates the
169-
resulting configuration, and persists it to Redis. If the updated configuration
170-
is identical to the current configuration, no operation is performed.
171-
172-
The update operation is atomic and uses optimistic locking with version checking.
173-
If a version mismatch occurs (another instance updated the config concurrently),
174-
the operation will fail and the caller should retry after reloading.
142+
Updates configuration with provided changes.
175143

176144
##### Parameters
177145

178146
###### updates
179147

180148
[`IRedisSMQConfig`](../interfaces/IRedisSMQConfig.md)
181149

182-
Partial configuration object containing the changes to apply
150+
Partial configuration to apply
183151

184152
##### Returns
185153

186154
`Promise`\<`void`\>
187155

188-
Promise that resolves when update is complete if callback not provided
189-
190-
##### Throws
191-
192-
If the updated configuration fails validation
156+
Promise if no callback, otherwise void
193157

194158
##### Example
195159

196-
```typescript
197-
// Update multiple settings
198-
await configManager.updateConfig({
199-
redis: { host: 'redis.example.com', port: 6379 },
200-
logger: { level: 'debug' },
201-
});
160+
```ts
161+
// Promise
162+
await configManager.updateConfig({ messageAudit: true });
202163

203-
// Using callback
204-
configManager.updateConfig({ redis: { host: 'new-host' } }, (err) => {
205-
if (err) {
206-
console.error('Update failed:', err);
207-
return;
208-
}
209-
console.log('Configuration updated successfully');
164+
// Callback
165+
configManager.updateConfig({ messageAudit: true }, (err) => {
166+
if (err) throw err;
210167
});
211168
```
212169

213170
#### Call Signature
214171

215172
> **updateConfig**(`updates`, `cb`): `void`
216173
217-
Updates the configuration with the provided changes.
218-
This method merges the updates with the current configuration, validates the
219-
resulting configuration, and persists it to Redis. If the updated configuration
220-
is identical to the current configuration, no operation is performed.
221-
222-
The update operation is atomic and uses optimistic locking with version checking.
223-
If a version mismatch occurs (another instance updated the config concurrently),
224-
the operation will fail and the caller should retry after reloading.
174+
Updates configuration with provided changes.
225175

226176
##### Parameters
227177

228178
###### updates
229179

230180
[`IRedisSMQConfig`](../interfaces/IRedisSMQConfig.md)
231181

232-
Partial configuration object containing the changes to apply
182+
Partial configuration to apply
233183

234184
###### cb
235185

236186
`ICallback`
237187

238-
Optional callback function for error-first pattern
188+
(err) => void
239189

240190
##### Returns
241191

242192
`void`
243193

244-
Promise that resolves when update is complete if callback not provided
245-
246-
##### Throws
247-
248-
If the updated configuration fails validation
194+
Promise if no callback, otherwise void
249195

250196
##### Example
251197

252-
```typescript
253-
// Update multiple settings
254-
await configManager.updateConfig({
255-
redis: { host: 'redis.example.com', port: 6379 },
256-
logger: { level: 'debug' },
257-
});
198+
```ts
199+
// Promise
200+
await configManager.updateConfig({ messageAudit: true });
258201

259-
// Using callback
260-
configManager.updateConfig({ redis: { host: 'new-host' } }, (err) => {
261-
if (err) {
262-
console.error('Update failed:', err);
263-
return;
264-
}
265-
console.log('Configuration updated successfully');
202+
// Callback
203+
configManager.updateConfig({ messageAudit: true }, (err) => {
204+
if (err) throw err;
266205
});
267206
```

0 commit comments

Comments
 (0)