@siglo/monitor 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -283,23 +283,30 @@ When scaling workflows across multiple worker processes or Kubernetes pods, aggr
|
|
|
283
283
|
|
|
284
284
|
```typescript
|
|
285
285
|
import { RedisMonitoringAdapter, createMonitorServer } from '@siglo/monitor';
|
|
286
|
+
import { WorkflowEventEmitter } from '@siglo/core';
|
|
287
|
+
import Redis from 'ioredis';
|
|
286
288
|
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
+
const redisUrl = process.env.REDIS_URL || 'redis://localhost:6379';
|
|
290
|
+
|
|
291
|
+
// 1. In Worker Process: Publish events to Redis
|
|
292
|
+
const publisher = new Redis(redisUrl);
|
|
293
|
+
const workerAdapter = new RedisMonitoringAdapter({
|
|
294
|
+
publisher,
|
|
289
295
|
channel: 'siglo:monitor:events'
|
|
290
296
|
});
|
|
291
297
|
|
|
292
|
-
// 1. In Worker Process: Publish events to Redis
|
|
293
298
|
emitter.on('*', (event) => {
|
|
294
|
-
|
|
299
|
+
workerAdapter.publish(event);
|
|
295
300
|
});
|
|
296
301
|
|
|
297
|
-
// 2. In Central Monitor Server:
|
|
302
|
+
// 2. In Central Monitor Server: Ingest events via subscriber and deliver to server emitter
|
|
303
|
+
const subscriber = new Redis(redisUrl);
|
|
298
304
|
const monitor = await createMonitorServer({ port: 4000 });
|
|
299
305
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
monitor
|
|
306
|
+
const serverAdapter = new RedisMonitoringAdapter({
|
|
307
|
+
subscriber,
|
|
308
|
+
channel: 'siglo:monitor:events',
|
|
309
|
+
emitter: monitor.emitter // Automatically routes incoming Redis events to monitor store & SSE
|
|
303
310
|
});
|
|
304
311
|
```
|
|
305
312
|
|