Skip to content

Commit 57fd27a

Browse files
committed
update at 2024-08-09 17:36:43
1 parent 37d5440 commit 57fd27a

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

pkg/clb/listener.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func CreateListener(ctx context.Context, region string, req *clb.CreateListenerR
6868
req.ListenerNames = []*string{common.StringPtr(TkePodListenerName)}
6969
client := GetClient(region)
7070
lbId := *req.LoadBalancerId
71-
mux := getLbLock(lbId)
72-
mux.Lock()
73-
defer mux.Unlock()
71+
mu := getLbLock(lbId)
72+
mu.Lock()
73+
defer mu.Unlock()
7474
resp, err := client.CreateListenerWithContext(ctx, req)
7575
if err != nil {
7676
return
@@ -109,9 +109,9 @@ func DeleteListener(ctx context.Context, region, lbId, listenerId string) error
109109
req.LoadBalancerId = &lbId
110110
req.ListenerId = &listenerId
111111
client := GetClient(region)
112-
mux := getLbLock(lbId)
113-
mux.Lock()
114-
defer mux.Unlock()
112+
mu := getLbLock(lbId)
113+
mu.Lock()
114+
defer mu.Unlock()
115115
resp, err := client.DeleteListenerWithContext(ctx, req)
116116
if err != nil {
117117
return err

pkg/clb/lock.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ var (
1010
func getLbLock(lbId string) *sync.Mutex {
1111
lock.Lock()
1212
defer lock.Unlock()
13-
mux, ok := lbLockMap[lbId]
13+
mu, ok := lbLockMap[lbId]
1414
if !ok {
15-
mux = &sync.Mutex{}
16-
lbLockMap[lbId] = mux
15+
mu = &sync.Mutex{}
16+
lbLockMap[lbId] = mu
1717
}
18-
return mux
18+
return mu
1919
}

pkg/clb/target.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ func (t Target) String() string {
103103
}
104104

105105
func DeregisterAllTargets(ctx context.Context, region, lbId, listenerId string) error {
106-
mux := getLbLock(lbId)
107-
mux.Lock()
108-
defer mux.Unlock()
106+
mu := getLbLock(lbId)
107+
mu.Lock()
108+
defer mu.Unlock()
109109
queryReq := clb.NewDescribeTargetsRequest()
110110
queryReq.LoadBalancerId = &lbId
111111
queryReq.ListenerIds = []*string{&listenerId}
@@ -132,9 +132,9 @@ func DeregisterAllTargets(ctx context.Context, region, lbId, listenerId string)
132132
}
133133

134134
func DeregisterTargetsForListener(ctx context.Context, region, lbId, listenerId string, targets ...Target) error {
135-
mux := getLbLock(lbId)
136-
mux.Lock()
137-
defer mux.Unlock()
135+
mu := getLbLock(lbId)
136+
mu.Lock()
137+
defer mu.Unlock()
138138
clbTargets := getClbTargets(targets)
139139
req := clb.NewDeregisterTargetsRequest()
140140
req.LoadBalancerId = &lbId
@@ -159,9 +159,9 @@ func getClbTargets(targets []Target) (clbTargets []*clb.Target) {
159159
}
160160

161161
func RegisterTargets(ctx context.Context, region, lbId, listenerId string, targets ...Target) error {
162-
mux := getLbLock(lbId)
163-
mux.Lock()
164-
defer mux.Unlock()
162+
mu := getLbLock(lbId)
163+
mu.Lock()
164+
defer mu.Unlock()
165165
clbTargets := getClbTargets(targets)
166166
req := clb.NewRegisterTargetsRequest()
167167
req.LoadBalancerId = &lbId

0 commit comments

Comments
 (0)