Skip to content

Commit 6e70f82

Browse files
authored
refactor(api): rename VALKEY_URL to QUEUE_VALKEY_URL for clarity (#464)
This change renames the VALKEY_URL configuration variable to QUEUE_VALKEY_URL to explicitly indicate its purpose as a queue backing store (for vote buffers, export/import queues). This naming distinction allows for future introduction of a separate CACHE_VALKEY_URL for general caching purposes if needed. The internal variable in the API initialization has also been renamed from 'valkey' to 'queueValkey' to match this semantic clarification. Deploy: api, math-updater
1 parent 3d4b15d commit 6e70f82

9 files changed

Lines changed: 15 additions & 15 deletions

File tree

services/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ EXPORT_CONVOS_S3_PRESIGNED_URL_EXPIRY_SECONDS=3600 # Presigned URL valid
9595
EXPORT_CONVOS_ENABLED=true # Enable/disable export feature (default: true)
9696

9797
# Optional: Valkey for export queue persistence across instances
98-
VALKEY_URL=redis://localhost:6379 # If not set, uses in-memory storage (lost on restart)
98+
QUEUE_VALKEY_URL=redis://localhost:6379 # If not set, uses in-memory storage (lost on restart)
9999
```
100100

101101
**Export Queue System:**

services/api/env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ VERIFICATOR_SVC_BASE_URL="http://verificator-svc"
1313

1414
# Valkey configuration (optional - for vote/export buffer persistence across instances)
1515
# If not set, buffers will use in-memory storage only (lost on restart)
16-
# VALKEY_URL="valkey://localhost:6379"
16+
# QUEUE_VALKEY_URL="valkey://localhost:6379"
1717
# NOSTR_PROOF_CHANNEL_EVENT_ID="6cde92f2a057368e4871d5dac0f830e09f399bad666a2070e4c4c6c40d235667"
1818
# NOSTR_DEFAULT_RELAY_URL="wss://nos.lol"
1919
POLIS_BASE_URL="http://127.0.0.1:5000"

services/api/src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,17 @@ if (
376376
}
377377

378378
// Initialize Valkey (optional - for vote buffer persistence)
379-
const valkey = await initializeValkey({ valkeyUrl: config.VALKEY_URL, log });
379+
const queueValkey = await initializeValkey({ valkeyUrl: config.QUEUE_VALKEY_URL, log });
380380

381381
// Initialize VoteBuffer (batches votes to reduce DB contention)
382382
const voteBuffer = createVoteBuffer({
383383
db,
384-
valkey,
384+
valkey: queueValkey,
385385
flushIntervalMs: config.VOTE_BUFFER_FLUSH_INTERVAL_MS,
386386
valkeyBatchLimit: config.VOTE_BUFFER_VALKEY_BATCH_LIMIT,
387387
});
388388
log.info(
389-
`[API] Vote buffer initialized (flush interval: ${String(config.VOTE_BUFFER_FLUSH_INTERVAL_MS)}ms, batch limit: ${String(config.VOTE_BUFFER_VALKEY_BATCH_LIMIT)}, persistence: ${valkey !== undefined ? "Valkey" : "in-memory only"})`,
389+
`[API] Vote buffer initialized (flush interval: ${String(config.VOTE_BUFFER_FLUSH_INTERVAL_MS)}ms, batch limit: ${String(config.VOTE_BUFFER_VALKEY_BATCH_LIMIT)}, persistence: ${queueValkey !== undefined ? "Valkey" : "in-memory only"})`,
390390
);
391391

392392
// Initialize Notification SSE Manager for real-time notifications
@@ -396,7 +396,7 @@ notificationSSEManager.initialize();
396396
// Initialize ExportBuffer (batches export requests to reduce system load)
397397
const exportBuffer = createExportBuffer({
398398
db,
399-
valkey,
399+
valkey: queueValkey,
400400
notificationSSEManager,
401401
flushIntervalMs: 1000,
402402
maxBatchSize: config.EXPORT_CONVOS_BUFFER_MAX_BATCH_SIZE,
@@ -408,13 +408,13 @@ const exportBuffer = createExportBuffer({
408408
config.EXPORT_CONVOS_BUFFER_STALE_CLEANUP_EVERY_N_FLUSHES,
409409
});
410410
log.info(
411-
`[API] Export buffer initialized (flush interval: 1s, max batch: ${String(config.EXPORT_CONVOS_BUFFER_MAX_BATCH_SIZE)}, cooldown: ${String(config.EXPORT_CONVOS_COOLDOWN_SECONDS)}s, persistence: ${valkey !== undefined ? "Valkey" : "in-memory only"})`,
411+
`[API] Export buffer initialized (flush interval: 1s, max batch: ${String(config.EXPORT_CONVOS_BUFFER_MAX_BATCH_SIZE)}, cooldown: ${String(config.EXPORT_CONVOS_COOLDOWN_SECONDS)}s, persistence: ${queueValkey !== undefined ? "Valkey" : "in-memory only"})`,
412412
);
413413

414414
// Initialize ImportBuffer (batches import requests to reduce system load)
415415
const importBuffer = createImportBuffer({
416416
db,
417-
valkey,
417+
valkey: queueValkey,
418418
notificationSSEManager,
419419
voteBuffer,
420420
axiosPolis,
@@ -426,7 +426,7 @@ const importBuffer = createImportBuffer({
426426
config.IMPORT_BUFFER_STALE_CLEANUP_EVERY_N_FLUSHES,
427427
});
428428
log.info(
429-
`[API] Import buffer initialized (flush interval: ${String(config.IMPORT_BUFFER_FLUSH_INTERVAL_MS)}ms, max batch: ${String(config.IMPORT_BUFFER_MAX_BATCH_SIZE)}, max concurrency: ${String(config.IMPORT_BUFFER_MAX_CONCURRENCY)}, persistence: ${valkey !== undefined ? "Valkey" : "in-memory only"})`,
429+
`[API] Import buffer initialized (flush interval: ${String(config.IMPORT_BUFFER_FLUSH_INTERVAL_MS)}ms, max batch: ${String(config.IMPORT_BUFFER_MAX_BATCH_SIZE)}, max concurrency: ${String(config.IMPORT_BUFFER_MAX_CONCURRENCY)}, persistence: ${queueValkey !== undefined ? "Valkey" : "in-memory only"})`,
430430
);
431431

432432
// Cleanup stuck imports/exports from previous server session

services/api/src/shared-backend/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const sharedConfigSchema = z.object({
3030
GOOGLE_APPLICATION_CREDENTIALS: z.string().optional(),
3131
// Valkey (optional - for vote buffer persistence across instances)
3232
// Empty strings are treated as undefined to prevent connection attempts
33-
VALKEY_URL: z
33+
QUEUE_VALKEY_URL: z
3434
.string()
3535
.optional()
3636
.transform((val) => (val === "" ? undefined : val)),

services/api/src/shared-backend/valkey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function parseValkeyUrl(urlString: string): ParsedValkeyUrl {
5353
* - Export buffer queue management
5454
* - Future: Distributed locks, rate limiting, etc.
5555
*
56-
* If VALKEY_URL is not provided, returns undefined and services fall back to in-memory only.
56+
* If QUEUE_VALKEY_URL is not provided, returns undefined and services fall back to in-memory only.
5757
*
5858
* Configuration:
5959
* - Local: valkey://localhost:6379

services/math-updater/src/shared-backend/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const sharedConfigSchema = z.object({
3030
GOOGLE_APPLICATION_CREDENTIALS: z.string().optional(),
3131
// Valkey (optional - for vote buffer persistence across instances)
3232
// Empty strings are treated as undefined to prevent connection attempts
33-
VALKEY_URL: z
33+
QUEUE_VALKEY_URL: z
3434
.string()
3535
.optional()
3636
.transform((val) => (val === "" ? undefined : val)),

services/math-updater/src/shared-backend/valkey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function parseValkeyUrl(urlString: string): ParsedValkeyUrl {
5353
* - Export buffer queue management
5454
* - Future: Distributed locks, rate limiting, etc.
5555
*
56-
* If VALKEY_URL is not provided, returns undefined and services fall back to in-memory only.
56+
* If QUEUE_VALKEY_URL is not provided, returns undefined and services fall back to in-memory only.
5757
*
5858
* Configuration:
5959
* - Local: valkey://localhost:6379

services/shared-backend/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const sharedConfigSchema = z.object({
2929
GOOGLE_APPLICATION_CREDENTIALS: z.string().optional(),
3030
// Valkey (optional - for vote buffer persistence across instances)
3131
// Empty strings are treated as undefined to prevent connection attempts
32-
VALKEY_URL: z
32+
QUEUE_VALKEY_URL: z
3333
.string()
3434
.optional()
3535
.transform((val) => (val === "" ? undefined : val)),

services/shared-backend/src/valkey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function parseValkeyUrl(urlString: string): ParsedValkeyUrl {
5252
* - Export buffer queue management
5353
* - Future: Distributed locks, rate limiting, etc.
5454
*
55-
* If VALKEY_URL is not provided, returns undefined and services fall back to in-memory only.
55+
* If QUEUE_VALKEY_URL is not provided, returns undefined and services fall back to in-memory only.
5656
*
5757
* Configuration:
5858
* - Local: valkey://localhost:6379

0 commit comments

Comments
 (0)