Skip to content

Commit e6efb3c

Browse files
authored
realtime: allow realtime streams to have it's own redis env vars (#1876)
1 parent 7b9ab17 commit e6efb3c

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

apps/webapp/app/env.server.ts

+32
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,38 @@ const EnvironmentSchema = z.object({
151151
CACHE_REDIS_TLS_DISABLED: z.string().default(process.env.REDIS_TLS_DISABLED ?? "false"),
152152
CACHE_REDIS_CLUSTER_MODE_ENABLED: z.string().default("0"),
153153

154+
REALTIME_STREAMS_REDIS_HOST: z
155+
.string()
156+
.optional()
157+
.transform((v) => v ?? process.env.REDIS_HOST),
158+
REALTIME_STREAMS_REDIS_READER_HOST: z
159+
.string()
160+
.optional()
161+
.transform((v) => v ?? process.env.REDIS_READER_HOST),
162+
REALTIME_STREAMS_REDIS_READER_PORT: z.coerce
163+
.number()
164+
.optional()
165+
.transform(
166+
(v) =>
167+
v ?? (process.env.REDIS_READER_PORT ? parseInt(process.env.REDIS_READER_PORT) : undefined)
168+
),
169+
REALTIME_STREAMS_REDIS_PORT: z.coerce
170+
.number()
171+
.optional()
172+
.transform((v) => v ?? (process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT) : undefined)),
173+
REALTIME_STREAMS_REDIS_USERNAME: z
174+
.string()
175+
.optional()
176+
.transform((v) => v ?? process.env.REDIS_USERNAME),
177+
REALTIME_STREAMS_REDIS_PASSWORD: z
178+
.string()
179+
.optional()
180+
.transform((v) => v ?? process.env.REDIS_PASSWORD),
181+
REALTIME_STREAMS_REDIS_TLS_DISABLED: z
182+
.string()
183+
.default(process.env.REDIS_TLS_DISABLED ?? "false"),
184+
REALTIME_STREAMS_REDIS_CLUSTER_MODE_ENABLED: z.string().default("0"),
185+
154186
PUBSUB_REDIS_HOST: z
155187
.string()
156188
.optional()

apps/webapp/app/services/realtime/v1StreamsGlobal.server.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { RedisRealtimeStreams } from "./redisRealtimeStreams.server";
55
function initializeRedisRealtimeStreams() {
66
return new RedisRealtimeStreams({
77
redis: {
8-
port: env.REDIS_PORT,
9-
host: env.REDIS_HOST,
10-
username: env.REDIS_USERNAME,
11-
password: env.REDIS_PASSWORD,
8+
port: env.REALTIME_STREAMS_REDIS_PORT,
9+
host: env.REALTIME_STREAMS_REDIS_HOST,
10+
username: env.REALTIME_STREAMS_REDIS_USERNAME,
11+
password: env.REALTIME_STREAMS_REDIS_PASSWORD,
1212
enableAutoPipelining: true,
13-
...(env.REDIS_TLS_DISABLED === "true" ? {} : { tls: {} }),
13+
...(env.REALTIME_STREAMS_REDIS_TLS_DISABLED === "true" ? {} : { tls: {} }),
1414
keyPrefix: "tr:realtime:streams:",
1515
},
1616
});

0 commit comments

Comments
 (0)