Skip to content

Commit fe54d5a

Browse files
committed
integrated retries
1 parent cd75e14 commit fe54d5a

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

localEvaluation/localEvaluation.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import (
1313
var (
1414
client *local.Client
1515
LocalEvaluationConfigDebug = true
16-
LocalEvaluationConfigServerUrl = "https://api.lambdatest.com"
16+
LocalEvaluationConfigServerUrl = "https://apii.lambdatest.com"
1717
LocalEvaluationConfigPollInterval = 120
1818
LocalEvaluationConfigPollerRequestTimeout = 60
1919
LocalEvaluationDeploymentKey = "server-jAqqJaX3l8PgNiJpcv9j20ywPzANQQFh"
20+
retries = 5
2021
)
2122

2223
type Variant struct {
@@ -73,7 +74,16 @@ func Initialize() {
7374
FlagConfigPollerRequestTimeout: time.Duration(LocalEvaluationConfigPollerRequestTimeout) * time.Second,
7475
}
7576
client = local.Initialize(LocalEvaluationDeploymentKey, &config)
76-
err := client.Start()
77+
var err error
78+
for i := 0; i < retries; i++ {
79+
err = client.Start()
80+
if err != nil {
81+
err = fmt.Errorf("unable to create local evaluation client with given config %+v attempt:%v with error %s", config, i+1, err.Error())
82+
continue
83+
} else {
84+
break
85+
}
86+
}
7787
if err != nil {
7888
err = fmt.Errorf("unable to create local evaluation client with given config %+v with error %s", config, err.Error())
7989
panic(err)
@@ -82,7 +92,16 @@ func Initialize() {
8292

8393
func InitializeWithConfig(conf local.Config, deploymentKey string) {
8494
client = local.Initialize(deploymentKey, &conf)
85-
err := client.Start()
95+
var err error
96+
for i := 0; i < retries; i++ {
97+
err = client.Start()
98+
if err != nil {
99+
err = fmt.Errorf("unable to create local evaluation client with given config %+v attempt:%v with error %s", conf, i+1, err.Error())
100+
continue
101+
} else {
102+
break
103+
}
104+
}
86105
if err != nil {
87106
err = fmt.Errorf("unable to create local evaluation client with given config %+v with error %s", conf, err.Error())
88107
panic(err)

0 commit comments

Comments
 (0)