Open PunRabbit opened 10 months ago
+1
I've also run into this issue and decided to implement my own redis health indicator.
@Injectable()
export class RedisHealthIndicator extends HealthIndicator {
constructor(@InjectRedis() private readonly redis: Redis) {
super();
}
async isHealthy(key: string): Promise<HealthIndicatorResult> {
try {
await this.redis.ping();
return this.getStatus(key, true);
} catch (error) {
throw new HealthCheckError('Redis check failed', this.getStatus(key, false, { message: error.message }));
}
}
}
The health indicator provided by @nest-modules/ioredis uses a custom provider for a redis health check instance which doesn't consider the configuration (see https://github.com/nest-modules/ioredis/blob/main/lib/indicator/redis-health.provider.ts#L6).
Theoretically this could be changed similar to my implementation. But I don't know what plans the lib maintainers have for the health checking feature 🤷🏻
@silas-joekel I invite you to add the solution to this repo, I could dedicate the weekend to this, but if you can add it, I would appreciate it.
I'm open to any improvement just leave your PRs
I am still working on an implementation for this, I hope I can solve this.
When I use RedisModule with forRootAsync method, I can choose connection url.
but, when I add RedisHealthModule, I can't choose connection url.
it just keep trying to connect with 127.0.0.1 address.
is there any way to choose connection url for Redis health check?
Here is the code below that I use.
and, this is what I got when I run application.
Thanks.