0

Add cancellable context for Redis operation to prevent hanging redis ops on shutdown

- Rename Ctx to RedisCtx with CancelRedisCtx function
- Signal handler now cancels context before closing Redis
This commit is contained in:
eleksir
2026-03-30 16:34:18 +03:00
parent 57b2c56b3f
commit 59643b6a0a
3 changed files with 18 additions and 7 deletions

View File

@@ -28,8 +28,11 @@ func SigHandler() {
continue
}
// Отменяем контекст редиски, чтобы все ожидающие операции завершились.
CancelRedisCtx()
// Отпишемся от всех каналов и закроем коннект к редиске.
if err = Subscriber.Unsubscribe(Ctx); err != nil {
if err = Subscriber.Unsubscribe(RedisCtx); err != nil {
log.Errorf("Unable to unsubscribe from redis channels cleanly: %s", err)
}