Skip to content

Commit 997c797

Browse files
committed
Max retry delay set to 2s, delay factor set as 1.2
1 parent 17a35a2 commit 997c797

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/plugin/client.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"io"
9+
"math"
910
"net/http"
1011
"net/url"
1112
"time"
@@ -103,7 +104,8 @@ func (d *DataSetClient) doPingRequest(ctx context.Context, req interface{}) (*LR
103104
var token string
104105

105106
delay := 1 * time.Second
106-
const maxDelay = 8 * time.Second
107+
const maxDelay = 2 * time.Second
108+
const delayFactor = 1.2
107109

108110
loop: for i := 0; ; i++ {
109111
resp, err := d.netClient.Do(request)
@@ -155,7 +157,10 @@ func (d *DataSetClient) doPingRequest(ctx context.Context, req interface{}) (*LR
155157
}
156158

157159
if delay < maxDelay {
158-
delay *= 2
160+
delay = time.Duration(math.Round(float64(delay) * delayFactor))
161+
if delay > maxDelay {
162+
delay = maxDelay
163+
}
159164
}
160165

161166
u := fmt.Sprintf("%s/v2/api/queries/%s?lastStepSeen=%d", d.dataSetUrl, respBody.Id, respBody.StepsCompleted)

0 commit comments

Comments
 (0)