Skip to content

Commit

Permalink
Merge pull request #2 from kumparan/hotfix/missing-connection-close
Browse files Browse the repository at this point in the history
Hotfix: missing connection close
  • Loading branch information
zhenqianz authored Jan 25, 2023
2 parents 3c63539 + 69586fd commit ef0ea84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 kumparan
Copyright (c) 2023 kumparan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 10 additions & 0 deletions restrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func (b Breaker) init(name string) (state string, openStateTTL time.Duration, er
ns := newNamespacer(name)

conn := b.redisPool.Get()
defer conn.Close()

err = conn.Send("MULTI")
if err != nil {
return
Expand Down Expand Up @@ -166,6 +168,8 @@ func (b Breaker) preRun(name string) (reqCount, errCount int, err error) {
ns := newNamespacer(name)

conn := b.redisPool.Get()
defer conn.Close()

err = conn.Send("MULTI")
if err != nil {
return
Expand Down Expand Up @@ -210,6 +214,8 @@ func (b Breaker) flipClose(name string) (err error) {
ns := newNamespacer(name)

conn := b.redisPool.Get()
defer conn.Close()

err = conn.Send("MULTI")
if err != nil {
return
Expand Down Expand Up @@ -239,6 +245,8 @@ func (b Breaker) flipOpen(name string) (err error) {
ns := newNamespacer(name)

conn := b.redisPool.Get()
defer conn.Close()

err = conn.Send("MULTI")
if err != nil {
return
Expand Down Expand Up @@ -268,6 +276,8 @@ func (b Breaker) recordError(name string) (err error) {
ns := newNamespacer(name)

conn := b.redisPool.Get()
defer conn.Close()

err = conn.Send("MULTI")
if err != nil {
return
Expand Down

0 comments on commit ef0ea84

Please sign in to comment.