Skip to content

Commit 6706276

Browse files
Copilotwarengonzaga
andcommitted
Update environment variable naming to match unthread-telegram-bot and hard-code queue configuration
Co-authored-by: warengonzaga <[email protected]>
1 parent 8aa5e3f commit 6706276

File tree

7 files changed

+26
-29
lines changed

7 files changed

+26
-29
lines changed

.env.example

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,15 @@ UNTHREAD_WEBHOOK_SECRET=your_unthread_webhook_secret_here
1313
DATABASE_URL=postgres://postgres:postgres@localhost:5432/unthread_discord_bot
1414

1515
# Redis Cache (L2) - Distributed cache layer
16-
REDIS_CACHE_URL=redis://localhost:6379
16+
PLATFORM_REDIS_URL=redis://localhost:6379
1717

18-
# Redis Queue (Optional) - Queue processing for webhooks
19-
REDIS_QUEUE_URL=redis://localhost:6380
18+
# Redis Queue - Queue processing for webhooks (automatically configured)
19+
WEBHOOK_REDIS_URL=redis://localhost:6380
2020

2121
# Optional Configuration
2222
FORUM_CHANNEL_IDS=channel_id_1,channel_id_2,channel_id_3
2323
DEBUG_MODE=false
2424
PORT=3000
2525

26-
# Queue Processing Configuration (Optional)
27-
QUEUE_CONCURRENCY=5
28-
QUEUE_MAX_RETRIES=3
29-
QUEUE_RETRY_DELAY=5000
30-
QUEUE_RATE_LIMIT_MAX=100
31-
QUEUE_RATE_LIMIT_DURATION=60000
32-
3326
# HTTP Timeout Configuration (Optional)
3427
UNTHREAD_HTTP_TIMEOUT_MS=15000

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ docker-compose up -d postgres redis-cache redis-queue
271271

272272
**Storage Configuration (3-Layer Architecture):**
273273
- `DATABASE_URL`: PostgreSQL connection string (e.g., `postgres://user:password@localhost:5432/database`)
274-
- `REDIS_CACHE_URL`: Redis cache connection URL (e.g., `redis://localhost:6379`)
275-
- `REDIS_QUEUE_URL`: Redis queue connection URL (e.g., `redis://localhost:6380`) - Optional, defaults to cache URL
274+
- `PLATFORM_REDIS_URL`: Redis cache connection URL (e.g., `redis://localhost:6379`)
275+
- `WEBHOOK_REDIS_URL`: Redis queue connection URL (e.g., `redis://localhost:6380`)
276276

277277
**Optional Configuration:**
278278
- `FORUM_CHANNEL_IDS`: Comma-separated list of forum channel IDs for automatic ticket creation.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ services:
7474

7575
# Storage Configuration
7676
DATABASE_URL: postgres://postgres:postgres@postgres:5432/unthread_discord_bot
77-
REDIS_CACHE_URL: redis://redis-cache:6379
78-
REDIS_QUEUE_URL: redis://redis-queue:6379
77+
PLATFORM_REDIS_URL: redis://redis-cache:6379
78+
WEBHOOK_REDIS_URL: redis://redis-queue:6379
7979

8080
# Optional Configuration
8181
FORUM_CHANNEL_IDS: ${FORUM_CHANNEL_IDS:-}

src/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
* - UNTHREAD_API_KEY: API key for Unthread integration
2525
* - UNTHREAD_SLACK_CHANNEL_ID: Slack channel ID for ticket routing
2626
* - UNTHREAD_WEBHOOK_SECRET: Secret for webhook signature verification
27-
* - REDIS_URL: Redis connection URL for caching and data persistence (required)
27+
* - DATABASE_URL: PostgreSQL connection URL for L3 persistent storage (required)
28+
* - PLATFORM_REDIS_URL: Redis connection URL for L2 cache layer (required)
29+
* - WEBHOOK_REDIS_URL: Redis connection URL for webhook queue processing (required)
2830
* - FORUM_CHANNEL_IDS: Comma-separated list of forum channel IDs for automatic ticket creation (optional)
2931
* - DEBUG_MODE: Enable verbose logging during development (optional, defaults to false)
3032
* - PORT: Port for webhook server (optional, defaults to 3000)
@@ -155,9 +157,10 @@ async function main(): Promise<void> {
155157
'UNTHREAD_SLACK_CHANNEL_ID',
156158
'UNTHREAD_WEBHOOK_SECRET',
157159
'DATABASE_URL',
158-
'REDIS_CACHE_URL',
160+
'PLATFORM_REDIS_URL',
161+
'WEBHOOK_REDIS_URL',
159162
];
160-
const { DISCORD_BOT_TOKEN, DATABASE_URL, REDIS_CACHE_URL } = process.env as Partial<BotConfig>;
163+
const { DISCORD_BOT_TOKEN, DATABASE_URL, PLATFORM_REDIS_URL } = process.env as Partial<BotConfig>;
161164

162165
const missingVars: string[] = [];
163166

@@ -190,8 +193,8 @@ async function main(): Promise<void> {
190193
process.exit(1);
191194
}
192195

193-
if (!REDIS_CACHE_URL) {
194-
LogEngine.error('REDIS_CACHE_URL is required for L2 cache layer');
196+
if (!PLATFORM_REDIS_URL) {
197+
LogEngine.error('PLATFORM_REDIS_URL is required for L2 cache layer');
195198
LogEngine.error('Please provide a valid Redis connection URL (e.g., redis://localhost:6379)');
196199
process.exit(1);
197200
}

src/sdk/bots-brain/BotsStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class BotsStore {
123123
public static async initialize(): Promise<BotsStore> {
124124
const config: BotsStoreConfig = {
125125
databaseUrl: process.env.DATABASE_URL || 'postgres://localhost:5432/unthread_discord_bot',
126-
redisCacheUrl: process.env.REDIS_CACHE_URL || 'redis://localhost:6379',
126+
redisCacheUrl: process.env.PLATFORM_REDIS_URL || 'redis://localhost:6379',
127127
// 1 hour default cache
128128
defaultCacheTtl: 3600,
129129
enableMetrics: process.env.DEBUG_MODE === 'true',

src/services/QueueProcessor.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ export class QueueProcessor {
138138
*/
139139
public static async initialize(): Promise<QueueProcessor> {
140140
const config: QueueConfig = {
141-
redisUrl: process.env.REDIS_QUEUE_URL || 'redis://localhost:6380',
142-
concurrency: parseInt(process.env.QUEUE_CONCURRENCY || '5'),
143-
maxRetries: parseInt(process.env.QUEUE_MAX_RETRIES || '3'),
144-
retryDelayMs: parseInt(process.env.QUEUE_RETRY_DELAY || '5000'),
145-
rateLimitMax: parseInt(process.env.QUEUE_RATE_LIMIT_MAX || '100'),
146-
rateLimitDuration: parseInt(process.env.QUEUE_RATE_LIMIT_DURATION || '60000'),
141+
// Hard-coded queue configuration as per requirements
142+
redisUrl: process.env.WEBHOOK_REDIS_URL || 'redis://localhost:6380',
143+
concurrency: 5,
144+
maxRetries: 3,
145+
retryDelayMs: 5000,
146+
rateLimitMax: 100,
147+
rateLimitDuration: 60000,
147148
enableMetrics: process.env.DEBUG_MODE === 'true',
148149
};
149150

src/types/discord.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ export interface BotConfig {
5858
/** PostgreSQL database URL for L3 storage (required) */
5959
DATABASE_URL: string;
6060
/** Redis cache URL for L2 storage (required) */
61-
REDIS_CACHE_URL: string;
62-
/** Redis queue URL for webhook processing (optional) */
63-
REDIS_QUEUE_URL?: string;
61+
PLATFORM_REDIS_URL: string;
62+
/** Redis queue URL for webhook processing (required) */
63+
WEBHOOK_REDIS_URL: string;
6464
/** Comma-separated list of forum channel IDs for auto-ticket creation (optional) */
6565
FORUM_CHANNEL_IDS?: string;
6666
/** Enable verbose logging for development (optional) */

0 commit comments

Comments
 (0)