Skip to content

Commit 6026108

Browse files
committed
remove global vars
1 parent 79f89cc commit 6026108

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

sdk/client/pollers/poller.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ import (
1616

1717
const DefaultNumberOfDroppedConnectionsToAllow = 3
1818

19-
var (
20-
pollingCancelledError = PollingCancelledError{}
21-
pollingDroppedConnectionError = PollingDroppedConnectionError{}
22-
pollingFailedError = PollingFailedError{}
23-
)
24-
2519
type Poller struct {
2620
// initialDelayDuration specifies the duration of the initial delay when polling
2721
// this is also used for retries should a `latestResponse` not be available, for
@@ -96,17 +90,17 @@ func (p *Poller) LatestResponse() *client.Response {
9690
// LatestStatus returns the latest status returned when polling
9791
func (p *Poller) LatestStatus() PollingStatus {
9892
if p.latestError != nil {
99-
if errors.As(p.latestError, &pollingCancelledError) {
93+
if errors.As(p.latestError, &PollingCancelledError{}) {
10094
return PollingStatusCancelled
10195
}
10296

103-
if errors.As(p.latestError, &pollingDroppedConnectionError) {
97+
if errors.As(p.latestError, &PollingDroppedConnectionError{}) {
10498
// we could look to expose a status for this, but we likely wouldn't handle this any differently
10599
// to it being unknown, so I (@tombuildsstuff) think this is reasonable for now?
106100
return PollingStatusUnknown
107101
}
108102

109-
if errors.As(p.latestError, &pollingFailedError) {
103+
if errors.As(p.latestError, &PollingFailedError{}) {
110104
return PollingStatusFailed
111105
}
112106

@@ -153,7 +147,7 @@ func (p *Poller) PollUntilDone(ctx context.Context) error {
153147
if p.latestResponse == nil && p.latestError == nil {
154148
// connection drops can either have no response/error (where we have no context)
155149
connectionHasBeenDropped = true
156-
} else if errors.As(p.latestError, &pollingDroppedConnectionError) {
150+
} else if errors.As(p.latestError, &PollingDroppedConnectionError{}) {
157151
// or have an error with more details (e.g. server not found, connection reset etc.)
158152
connectionHasBeenDropped = true
159153
}

0 commit comments

Comments
 (0)