File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,9 @@ func (r *RedisManager) getShardLockKey(session dto.Session) string {
129
129
// 如果不能,则清理掉 sessionID,将 session 放入 sessionChan 中
130
130
// session 的启动,交给 start 中的 for 循环执行,session 不自己递归进行重连,避免递归深度过深
131
131
func (r * RedisManager ) newConnect (session dto.Session ) {
132
- ctx := context .Background ()
132
+ ctx , cancel := context .WithCancel (context .Background ())
133
+ defer cancel ()
134
+
133
135
// 锁 shard,避免针对相同 shard 消费重复了
134
136
shardLock := lock .New (r .getShardLockKey (session ), uuid .NewString (), r .client )
135
137
if err := shardLock .Lock (ctx , shardLockExpireTime ); err != nil {
Original file line number Diff line number Diff line change @@ -42,17 +42,11 @@ type AccessTokenInfo struct {
42
42
UpTime time.Time
43
43
}
44
44
45
- var authTokenInstance * AuthTokenInfo
46
- var once sync.Once
47
-
48
45
func NewAuthTokenInfo () * AuthTokenInfo {
49
- once .Do (func () {
50
- authTokenInstance = & AuthTokenInfo {
51
- lock : & sync.RWMutex {},
52
- forceUpToken : make (chan interface {}, 10 ),
53
- }
54
- })
55
- return authTokenInstance
46
+ return & AuthTokenInfo {
47
+ lock : & sync.RWMutex {},
48
+ forceUpToken : make (chan interface {}, 10 ),
49
+ }
56
50
}
57
51
58
52
// ForceUpToken 强制刷新Token
You can’t perform that action at this time.
0 commit comments