mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-21 06:37:21 +00:00
Enhance the retry logic for the proxied queries.
This commit is contained in:
@@ -57,20 +57,29 @@ func proxyTheRequest(c *fiber.Ctx, currentEndpoint string) error {
|
|||||||
|
|
||||||
err = retry.Do(
|
err = retry.Do(
|
||||||
func() error {
|
func() error {
|
||||||
return proxy.DoRedirects(c, proxyURL, 3, cfg.Client.FastProxyClient)
|
proxyErr := proxy.DoRedirects(c, proxyURL, 3, cfg.Client.FastProxyClient)
|
||||||
|
if proxyErr != nil {
|
||||||
|
return proxyErr
|
||||||
|
}
|
||||||
|
if c.Response().StatusCode() != 200 {
|
||||||
|
return fmt.Errorf("received non-200 response from the GraphQL server: %d", c.Response().StatusCode())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
|
retry.Attempts(5),
|
||||||
|
retry.DelayType(retry.BackOffDelay),
|
||||||
|
retry.Delay(250*time.Millisecond),
|
||||||
|
retry.MaxDelay(5*time.Second),
|
||||||
retry.OnRetry(func(n uint, err error) {
|
retry.OnRetry(func(n uint, err error) {
|
||||||
cfg.Logger.Warning(&libpack_logger.LogMessage{
|
cfg.Logger.Warning(&libpack_logger.LogMessage{
|
||||||
Message: "Retrying the request",
|
Message: "Retrying the request",
|
||||||
Pairs: map[string]interface{}{
|
Pairs: map[string]interface{}{
|
||||||
"path": c.Path(),
|
"path": c.Path(),
|
||||||
"error": err.Error(),
|
"attempt": n + 1,
|
||||||
|
"error": err.Error(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
retry.Attempts(3),
|
|
||||||
retry.DelayType(retry.BackOffDelay),
|
|
||||||
retry.Delay(250*time.Millisecond),
|
|
||||||
retry.LastErrorOnly(true),
|
retry.LastErrorOnly(true),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user