@junando/worker 0.6.1 → 0.6.2
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 +75 -0
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @junando/worker
|
|
2
|
+
|
|
3
|
+
AWS Lambda SQS worker for the Junando alerting platform. Consumes messages from the SQS FIFO queue published by `@junando/webhook`, and executes the full incident processing pipeline: clustering, deduplication, trace fetching, LLM analysis, and notification dispatch.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @junando/worker
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @junando/worker
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Deploy as an AWS Lambda function triggered by the SQS FIFO queue. The `handler` export is compatible with `SQSEvent`.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { handler } from '@junando/worker'
|
|
19
|
+
|
|
20
|
+
export { handler }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
SQS FIFO queue
|
|
27
|
+
↓
|
|
28
|
+
handler (validates message schema with Zod)
|
|
29
|
+
↓
|
|
30
|
+
ProcessIncidentUseCase.execute()
|
|
31
|
+
├── ClusteringService — groups alerts by root cause
|
|
32
|
+
├── RedisDeduplicationStore — skips already-processed clusters
|
|
33
|
+
├── LokiTraceRepository — fetches relevant log traces
|
|
34
|
+
├── LLM (Claude / Gemini) — analyzes root cause
|
|
35
|
+
└── Notifier (Slack / Teams) — dispatches alert
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Reliability characteristics:**
|
|
39
|
+
- Dependencies are lazily initialized on the first invocation — SSM SecureStrings are read at runtime, not module load
|
|
40
|
+
- Invalid message schemas are logged and skipped (no retry) to avoid infinite SQS loops
|
|
41
|
+
- Schema-valid but processing-failed messages re-throw so SQS retries automatically
|
|
42
|
+
- `flushLoki()` runs in `finally` — logs always reach Loki even if the use case throws
|
|
43
|
+
|
|
44
|
+
## Environment variables
|
|
45
|
+
|
|
46
|
+
All configuration is loaded via `@junando/core`'s `loadConfig()`, which reads from AWS SSM Parameter Store or environment variables.
|
|
47
|
+
|
|
48
|
+
| Variable | Description |
|
|
49
|
+
|----------|-------------|
|
|
50
|
+
| `REDIS_URL` | Redis connection URL for deduplication |
|
|
51
|
+
| `LOKI_URL` | Loki URL for trace fetching |
|
|
52
|
+
| `SQS_QUEUE_URL` | Source SQS queue URL |
|
|
53
|
+
| `LLM_PROVIDER` | `claude` or `gemini` |
|
|
54
|
+
| `NOTIFIER` | `slack` or `teams` |
|
|
55
|
+
|
|
56
|
+
## SQS message schema
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
{
|
|
60
|
+
correlationId: string // UUID
|
|
61
|
+
alerts: NormalizedAlert[]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Requirements
|
|
66
|
+
|
|
67
|
+
- Node.js >= 24
|
|
68
|
+
- AWS Lambda runtime triggered by SQS
|
|
69
|
+
- Redis (for deduplication)
|
|
70
|
+
- Loki (for trace fetching)
|
|
71
|
+
- AWS credentials (for SSM + LLM if using Claude via Bedrock)
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junando/worker",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "AWS Lambda SQS worker — processes alert events and dispatches notifications for Junando",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/handler.js",
|
|
8
8
|
"files": [
|
|
9
|
-
"dist"
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
10
11
|
],
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"@aws-sdk/client-ssm": "^3.600.0",
|
|
22
23
|
"ioredis": "^5.4.1",
|
|
23
24
|
"zod": "^3.23.0",
|
|
24
|
-
"@junando/core": "0.6.
|
|
25
|
+
"@junando/core": "0.6.2"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@types/aws-lambda": "^8.10.145",
|