feat(redis-bullmq): Redis module, BullMQ queues, cache helpers, metrics - #119
Merged
Conversation
Redis client (src/redis/): - config.ts: buildRedisConfig() from env vars; TTL constants as single source of truth (nonce 5m, rate-limit 60s, policy 30s, claim 10s); key naming convention documented. - client.ts: singleton ioredis with lazyConnect, exponential backoff, enableOfflineQueue:false; separate getBullMQConnection() for BullMQ blocking commands; checkRedisHealth() with 2s timeout; graceful close. - cache.ts: cacheGet/Set/Del with graceful degradation; domain helpers for policy/claim caches; setNonce/consumeNonce (atomic GET+DEL via Lua, fail closed); incrementRateLimit (fail open). - metrics.ts: collectRedisMetrics() memory usage + per-queue depth; exposed via GET /metrics/redis. BullMQ queues (src/queues/): - names.ts: canonical QUEUE_NAMES constant (claim-events, claim-payouts). - claimEvents.queue.ts: producer with 5-attempt exponential backoff, removeOnComplete/Fail limits, closeClaimEventsQueue() for shutdown. - claimEvents.worker.ts: worker with concurrency:5, stalledInterval:30s, maxStalledCount:2; completed/failed/stalled/error event logging. Application wiring: - index.ts: GET /health/ready (Redis-aware, 503 on down), GET /metrics/redis. - server.ts: production entry point with SIGTERM/SIGINT handlers (separated from index.ts so tests import without side effects). Tests (src/__tests__/): - health.test.ts: /health, /health/ready, /metrics/redis shape no Redis. - redis.cache.test.ts: cache round-trip, TTL expiry, nonce atomicity, rate-limit increment skipped if REDIS_HOST not set. - claimEvents.queue.test.ts: end-to-end job processing, retry on failure skipped if REDIS_HOST not set; unit shape test always runs. Infrastructure: - docker-compose.yml: Redis 7-alpine with password, maxmemory 256mb, allkeys-lru, healthcheck. - .env.example: all required env vars documented. - ci.yml: Redis service container added to backend job; REDIS_HOST/PORT env vars set so integration tests run in CI. Config: - tsconfig.json: target ES2022 (Error.cause support); exclude __tests__. - tsconfig.test.json: extends base, adds jest types for test files. - package.json: bullmq, ioredis deps; @types/jest, supertest devDeps; ts-jest pointed at tsconfig.test.json. Docs: - backend/REDIS.md: outage behaviour table, key naming, TTL conventions, queue config rationale, metrics alert thresholds, production checklist.
|
@zeekman Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Backend (Node/TypeScript): - tsconfig.json: remove types array (causes pre-install error); restored with types:[node] since skipLibCheck handles missing @types before install - tsconfig.test.json: add types:[node,jest]; remove redundant exclude - eslint.config.mjs: rewrite for ESLint 9 flat config; add ignores for dist/; disable no-floating-promises for express handlers; fix --ext flag (ignored in flat config) by updating lint script to 'eslint src' - package.json: add @types/jest devDep; update lint script; point ts-jest at tsconfig.test.json - claimEvents.worker.ts: add explicit Job<ClaimEventJobData> types on worker.on callbacks to fix implicit any under strict mode - ci.yml: add --health-start-period 5s to Redis service options Contract (Rust/Soroban): - admin.rs: add missing file (lib.rs declares pub mod admin; build fails without it); contains AdminError, require_admin, all admin entrypoints - storage.rs: add Paused/PendingAdmin DataKey variants and helpers; switch next_policy_id/next_claim_id to checked_add (overflow safety) - token.rs: add transfer_from_contract (used by admin::drain) and allowlist enforcement in transfer; remove dead_code allow - validate.rs: remove DuplicateVote variant (unused; -D warnings = error)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #47