fix: recover transient stock history failures within bounded deadlines
This commit is contained in:
@@ -19,7 +19,7 @@ func NewRouter(health *service.HealthService, logger *zap.Logger, identity Ident
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
r := gin.New()
|
||||
r.Use(func(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 5*time.Second)
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), requestTimeout(c.Request))
|
||||
defer cancel()
|
||||
if identity.PublicOrigin != "" {
|
||||
ctx = context.WithValue(ctx, publicOriginContextKey{}, identity.PublicOrigin)
|
||||
@@ -87,3 +87,10 @@ func NewRouter(health *service.HealthService, logger *zap.Logger, identity Ident
|
||||
})
|
||||
return r
|
||||
}
|
||||
|
||||
func requestTimeout(r *http.Request) time.Duration {
|
||||
if r.Method == http.MethodGet && (r.URL.Path == "/api/admin/v1/market/history" || r.URL.Path == "/api/v1/market/history") || r.Method == http.MethodPost && r.URL.Path == "/api/admin/v1/backtests/from-market" {
|
||||
return 35 * time.Second
|
||||
}
|
||||
return 5 * time.Second
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user