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

Commit 47f4640

Browse files
authored
Retry refreshing credentials (#245)
* Retry refreshing credentials Don't exit the refresh goroutine on error, retry instead. * update changelog and version info
1 parent d677564 commit 47f4640

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## `v0.10.16`
4+
5+
- fixed an issue where links weren't being closed when retrying
6+
- fixed an issue where auto-refreshing of claims would exit due to a transient error
7+
38
## `v0.10.15`
49

510
- fix issue where deferring a message could result us encoding it incorrectly and sending the sequence

namespace.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252
//`
5353

5454
// Version is the semantic version number
55-
Version = "0.10.11"
55+
Version = "0.10.16"
5656

5757
rootUserAgent = "/golang-service-bus"
5858

@@ -266,10 +266,20 @@ func (ns *Namespace) negotiateClaim(ctx context.Context, client *amqp.Client, en
266266
case <-time.After(15 * time.Minute):
267267
refreshCtx, span := ns.startSpanFromContext(refreshCtx, "sb.namespace.negotiateClaim.refresh")
268268
defer span.End()
269-
if err := cbs.NegotiateClaim(refreshCtx, audience, client, ns.TokenProvider); err != nil {
269+
// refresh credentials until it succeeds
270+
for {
271+
err := cbs.NegotiateClaim(refreshCtx, audience, client, ns.TokenProvider)
272+
if err == nil {
273+
break
274+
}
275+
// the refresh failed, wait a few seconds then try again
270276
tab.For(refreshCtx).Error(err)
271-
// if auth failed cancel auto-refresh
272-
cancel()
277+
select {
278+
case <-refreshCtx.Done():
279+
break
280+
case <-time.After(5 * time.Second):
281+
// retry
282+
}
273283
}
274284
}
275285
}

0 commit comments

Comments
 (0)