Tested by creating Golang-http and Golang-middleware functions with a 5s wait inside. These were then deployed to Docker Swarm and invoked. Previously they choked at 3s.
package function
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
func Handle(w http.ResponseWriter, r *http.Request) {
var input []byte
if r.Body != nil {
defer r.Body.Close()
body, _ := ioutil.ReadAll(r.Body)
input = body
}
time.Sleep(5 * time.Second)
w.WriteHeader(http.StatusOK)
w.Write([]byte(fmt.Sprintf("Nice sleep, input was: %s", string(input))))
}
space-mini:golang-http-template alex$ time curl -d test http://127.0.0.1:8080/function
/golang-middleware1
Nice sleep, input was: test
real 0m5.023s
user 0m0.005s
sys 0m0.004s
space-mini:golang-http-template alex$
space-mini:golang-http-template alex$ time curl -d "test" http://127.0.0.1:8080/functi
on/golang-http1
Nice sleep, input was: test
real 0m5.021s
user 0m0.004s
sys 0m0.004s
space-mini:golang-http-template alex$
Setting the timeout value to 2s then gave a premature failure, as expected:
space-mini:golang-http-template alex$ time curl -d "test" http://127.0.0.1:8080/functi
on/golang-http1
Nice sleep, input was: test
real 0m5.021s
user 0m0.004s
sys 0m0.004s
How are existing users impacted? What migration steps/scripts do we need?
It should be a no-harm change. The default (10s) is larger than the previous 3s.
Checklist:
I have:
[x] updated the documentation and/or roadmap (if required)
Signed-off-by: Alex Ellis alexellis2@gmail.com
Description
Fixes: #20
Closes: #22
How Has This Been Tested?
Tested by creating Golang-http and Golang-middleware functions with a 5s wait inside. These were then deployed to Docker Swarm and invoked. Previously they choked at 3s.
Setting the timeout value to 2s then gave a premature failure, as expected:
The fail-back behaviour for legacy users / templates / docs of using an integer vs. Golang duration for timeouts is also now working as expected:
Result:
How are existing users impacted? What migration steps/scripts do we need?
It should be a no-harm change. The default (10s) is larger than the previous 3s.
Checklist:
I have:
git commit -s