mirror of
https://github.com/lukaszraczylo/go-simple-graphql.git
synced 2026-10-19 01:27:43 +00:00
Add missing retry mechanism.
I have no idea how this was missed, but ho hum.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/avast/retry-go/v4"
|
"github.com/avast/retry-go/v4"
|
||||||
)
|
)
|
||||||
@@ -50,6 +51,13 @@ func (c *BaseClient) executeQuery(query []byte, headers any) (result any, err er
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
retry.OnRetry(func(n uint, err error) {
|
||||||
|
c.Logger.Error(c, "Retrying query", "error", err.Error())
|
||||||
|
}),
|
||||||
|
retry.Attempts(uint(c.retries.max)),
|
||||||
|
retry.DelayType(retry.BackOffDelay),
|
||||||
|
retry.Delay(time.Duration(c.retries.delay)*time.Second),
|
||||||
|
retry.LastErrorOnly(true),
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(queryResult.Errors) > 0 {
|
if len(queryResult.Errors) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user