fixup set connected in hook
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
7fc5a26347
commit
e19c67ccc5
18
event.go
18
event.go
@ -37,8 +37,13 @@ func (h *eventHook) DialHook(hook goredis.DialHook) goredis.DialHook {
|
|||||||
func (h *eventHook) ProcessHook(hook goredis.ProcessHook) goredis.ProcessHook {
|
func (h *eventHook) ProcessHook(hook goredis.ProcessHook) goredis.ProcessHook {
|
||||||
return func(ctx context.Context, cmd goredis.Cmder) error {
|
return func(ctx context.Context, cmd goredis.Cmder) error {
|
||||||
err := hook(ctx, cmd)
|
err := hook(ctx, cmd)
|
||||||
if err != nil && !isRedisError(err) {
|
if err != nil {
|
||||||
h.connected.Store(false)
|
if !isRedisError(err) {
|
||||||
|
h.connected.Store(false)
|
||||||
|
}
|
||||||
|
h.connected.Store(true)
|
||||||
|
} else {
|
||||||
|
h.connected.Store(true)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -47,8 +52,13 @@ func (h *eventHook) ProcessHook(hook goredis.ProcessHook) goredis.ProcessHook {
|
|||||||
func (h *eventHook) ProcessPipelineHook(hook goredis.ProcessPipelineHook) goredis.ProcessPipelineHook {
|
func (h *eventHook) ProcessPipelineHook(hook goredis.ProcessPipelineHook) goredis.ProcessPipelineHook {
|
||||||
return func(ctx context.Context, cmds []goredis.Cmder) error {
|
return func(ctx context.Context, cmds []goredis.Cmder) error {
|
||||||
err := hook(ctx, cmds)
|
err := hook(ctx, cmds)
|
||||||
if err != nil && !isRedisError(err) {
|
if err != nil {
|
||||||
h.connected.Store(false)
|
if !isRedisError(err) {
|
||||||
|
h.connected.Store(false)
|
||||||
|
}
|
||||||
|
h.connected.Store(true)
|
||||||
|
} else {
|
||||||
|
h.connected.Store(true)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user