Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit d677564

Browse files
authored
defer close the link! (#244)
* defer close the link! * nicer wrapping * fold error handling to avoid variable shadowing and make scopes clearer * fix return * revert to simplest change possible
1 parent cb1ca62 commit d677564

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rpc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ func (r *rpcClient) doRPCWithRetry(ctx context.Context, address string, msg *amq
129129
var err error
130130
link, err = rpc.NewLink(client, address, opts...)
131131
if err == nil {
132+
defer func() {
133+
if link == nil {
134+
return
135+
}
136+
link.Close(ctx)
137+
}()
132138
rsp, err = link.RetryableRPC(ctx, times, delay, msg)
133139
if err == nil {
134140
return rsp, err

0 commit comments

Comments
 (0)