Open
Conversation
…tocol#20) Add StorageService with ioredis to persist aggregated prices with TTL, maintain per-symbol time-series history via Sorted Sets, and expose batch read/write operations for the API service. - StorageService: storePrice, getLatestPrice, getPriceHistory, storePriceBatch, getLatestPriceBatch, getTrackedSymbols, deleteSymbol - Redis key schema: latest (STRING+TTL), history (ZSET), symbols (SET) - Auto-reconnection via ioredis retryStrategy (exponential back-off) - No-op mode when REDIS_URL is unset — service starts cleanly - StorageModule (NestJS feature module) + storage-options.interface.ts - redis.config.ts ConfigFactory for REDIS_* env vars - 3 new Prometheus metrics: cache hits/misses + operation duration - AggregationService wired to fire-and-forget storePrice on each aggregation - 52 unit tests with mocked ioredis (>95% line coverage) - docker-compose.yml with Redis 7.2-alpine, LRU eviction, health check - Fix app.module.ts: missing HttpModule/EventEmitterModule imports, duplicate ConfigModule.forRoot, remove duplicate axios in package.json - README: Redis Storage section with key schema, env vars, metrics table
SchedulerService was used in providers and exports but not imported, causing a TypeScript compile error that was already present on main.
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.
feat(aggregator): implement Redis-backed Data Storage Layer
Summary
StorageServicebacked by Redis (ioredis) to persist aggregated prices with configurable TTLREDIS_URLis not configured — the service starts cleanly and aggregation is never interruptedStorageServicedocker-compose.ymlat the project root with a Redis 7.2-alpine serviceSchedulerServiceimport)Redis Key Schema
price:latest:{SYMBOL}REDIS_PRICE_TTL_SECONDS(default 300 s)price:history:{SYMBOL}computedAtms)price:symbolsNew Environment Variables
REDIS_URLREDIS_PRICE_TTL_SECONDS300REDIS_HISTORY_MAX_ENTRIES100REDIS_KEY_PREFIXpriceFiles Changed
New Files
apps/aggregator/src/services/storage.service.ts— Core Redis service with 9 public methodsapps/aggregator/src/services/storage.service.spec.ts— 52 unit tests (>95% line coverage)apps/aggregator/src/modules/storage.module.ts— NestJS feature moduleapps/aggregator/src/interfaces/storage-options.interface.ts— Typed options interfacesapps/aggregator/src/config/redis.config.ts— ConfigFactory for Redis env varsdocker-compose.yml— Redis 7.2-alpine with health check and LRU eviction policyModified Files
apps/aggregator/src/services/aggregation.service.ts— InjectsStorageService @Optional(), callsstorePricefire-and-forget after each aggregationapps/aggregator/src/metrics/metrics.service.ts— AddsstorageCacheHits,storageCacheMisses,storageOperationDurationPrometheus instrumentsapps/aggregator/src/app.module.ts— RegistersStorageModule; also fixes pre-existing bugs (missingHttpModule/EventEmitterModuleimports, duplicateConfigModule.forRoot)apps/aggregator/package.json— Removes duplicateaxiosentryapps/aggregator/.env.example— Documents all 4REDIS_*environment variablesapps/aggregator/README.md— Adds Redis Storage section with schema, env vars, metrics, and graceful degradation docsapps/ingestor/src/modules/prices.module.ts— Fixes missingSchedulerServiceimport (pre-existing build error)How to Test
Closes #20