mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-14 14:38:51 +01:00
feat: Add USE_REDIS_STREAMS configuration for stream job storage
- Introduced USE_REDIS_STREAMS to control Redis usage for resumable stream job storage, defaulting to true if USE_REDIS is enabled but not explicitly set. - Updated cacheConfig to include USE_REDIS_STREAMS and modified createStreamServices to utilize this new configuration. - Enhanced unit tests to validate the behavior of USE_REDIS_STREAMS under various environment settings, ensuring correct defaults and overrides.
This commit is contained in:
parent
cf963ca345
commit
4b598808be
3 changed files with 64 additions and 4 deletions
|
|
@ -49,14 +49,17 @@ export interface StreamServices {
|
|||
/**
|
||||
* Create stream services (job store + event transport).
|
||||
*
|
||||
* Automatically detects Redis from cacheConfig.USE_REDIS and uses
|
||||
* Automatically detects Redis from cacheConfig.USE_REDIS_STREAMS and uses
|
||||
* the existing ioredisClient. Falls back to in-memory if Redis
|
||||
* is not configured or not available.
|
||||
*
|
||||
* USE_REDIS_STREAMS defaults to USE_REDIS if not explicitly set,
|
||||
* allowing users to disable Redis for streams while keeping it for other caches.
|
||||
*
|
||||
* @example Auto-detect (uses cacheConfig)
|
||||
* ```ts
|
||||
* const services = createStreamServices();
|
||||
* // Uses Redis if USE_REDIS=true, otherwise in-memory
|
||||
* // Uses Redis if USE_REDIS_STREAMS=true (defaults to USE_REDIS), otherwise in-memory
|
||||
* ```
|
||||
*
|
||||
* @example Force in-memory
|
||||
|
|
@ -65,8 +68,8 @@ export interface StreamServices {
|
|||
* ```
|
||||
*/
|
||||
export function createStreamServices(config: StreamServicesConfig = {}): StreamServices {
|
||||
// Use provided config or fall back to cache config
|
||||
const useRedis = config.useRedis ?? cacheConfig.USE_REDIS;
|
||||
// Use provided config or fall back to cache config (USE_REDIS_STREAMS for stream-specific override)
|
||||
const useRedis = config.useRedis ?? cacheConfig.USE_REDIS_STREAMS;
|
||||
const redisClient = config.redisClient ?? ioredisClient;
|
||||
const { redisSubscriber, inMemoryOptions } = config;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue