mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
functions: fix route timeout (#349)
* functions: add route-level timeout configuration options * functions: harmonize defaults
This commit is contained in:
@@ -179,7 +179,7 @@ func (s *Server) serve(ctx context.Context, c *gin.Context, appName string, foun
|
||||
Memory: found.Memory,
|
||||
Stdin: payload,
|
||||
Stdout: &stdout,
|
||||
Timeout: 30 * time.Second,
|
||||
Timeout: time.Duration(found.Timeout) * time.Second,
|
||||
}
|
||||
|
||||
switch found.Type {
|
||||
@@ -216,12 +216,14 @@ func (s *Server) serve(ctx context.Context, c *gin.Context, appName string, foun
|
||||
c.Header(k, v[0])
|
||||
}
|
||||
|
||||
if result.Status() == "success" {
|
||||
switch result.Status() {
|
||||
case "success":
|
||||
c.Data(http.StatusOK, "", stdout.Bytes())
|
||||
} else {
|
||||
case "timeout":
|
||||
c.AbortWithStatus(http.StatusGatewayTimeout)
|
||||
default:
|
||||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user