refactor: simplify Redis configuration initialization
- Use RedisConfig::fromEnvironment() in LoggerInitializer - Remove fallback logic in QueueInitializer, always use connection pool - Make RedisConfig constructor private - Clean up Redis connection error message
This commit is contained in:
@@ -32,19 +32,9 @@ final readonly class QueueInitializer
|
||||
}
|
||||
|
||||
// Try to use Redis connection pool if available, otherwise create direct connection
|
||||
$redisConnection = null;
|
||||
if ($this->container->has(RedisConnectionPool::class)) {
|
||||
$pool = $this->container->get(RedisConnectionPool::class);
|
||||
$redisConnection = $pool->getQueueConnection();
|
||||
} else {
|
||||
// Fallback to direct connection creation
|
||||
$redisConfig = new RedisConfig(
|
||||
host: 'redis',
|
||||
port: 6379,
|
||||
database: 2 // Use DB 2 for queue
|
||||
);
|
||||
$redisConnection = new RedisConnection($redisConfig, 'queue');
|
||||
}
|
||||
|
||||
$pool = $this->container->get(RedisConnectionPool::class);
|
||||
$redisConnection = $pool->getQueueConnection();
|
||||
|
||||
return new RedisQueue(
|
||||
connection: $redisConnection,
|
||||
|
||||
Reference in New Issue
Block a user