fn: pure-runner time out while waiting TryCall (#1006)

This should return a retriable error code 503.
This commit is contained in:
Tolga Ceylan
2018-05-17 15:00:50 -07:00
committed by GitHub
parent 8c2c6286dc
commit 7cf8e2a61d
2 changed files with 19 additions and 1 deletions

View File

@@ -23,9 +23,11 @@ import (
"github.com/golang/protobuf/ptypes/empty"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/status"
)
/*
@@ -420,6 +422,10 @@ func (ch *callHandle) getTryMsg() *runner.TryCall {
select {
case <-ch.doneQueue:
case <-ch.ctx.Done():
// if ctx timed out while waiting, then this is a 503 (retriable)
err := status.Errorf(codes.Code(models.ErrCallTimeoutServerBusy.Code()), models.ErrCallTimeoutServerBusy.Error())
ch.shutdown(err)
return nil
case item := <-ch.inQueue:
if item != nil {
msg = item.GetTry()