mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
improve grpc error handling
This commit is contained in:
parent
438d5081dc
commit
ba23d05231
2 changed files with 54 additions and 69 deletions
69
vendor/github.com/cncd/pipeline/pipeline/rpc/client_grpc.go
generated
vendored
69
vendor/github.com/cncd/pipeline/pipeline/rpc/client_grpc.go
generated
vendored
|
@ -9,8 +9,11 @@ import (
|
|||
"github.com/cncd/pipeline/pipeline/rpc/proto"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
var backoff = time.Second
|
||||
|
||||
type client struct {
|
||||
client proto.DroneClient
|
||||
conn *grpc.ClientConn
|
||||
|
@ -38,17 +41,13 @@ func (c *client) Next(ctx context.Context, f Filter) (*Pipeline, error) {
|
|||
req.Filter.Labels = f.Labels
|
||||
for {
|
||||
res, err = c.client.Next(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
|
||||
println("error getting next execution. retry. " + err.Error())
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return nil, err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
|
||||
if res.GetPipeline() == nil {
|
||||
|
@ -69,15 +68,13 @@ func (c *client) Wait(ctx context.Context, id string) (err error) {
|
|||
req.Id = id
|
||||
for {
|
||||
_, err = c.client.Wait(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -95,15 +92,13 @@ func (c *client) Init(ctx context.Context, id string, state State) (err error) {
|
|||
req.State.Name = state.Proc
|
||||
for {
|
||||
_, err = c.client.Init(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -121,15 +116,13 @@ func (c *client) Done(ctx context.Context, id string, state State) (err error) {
|
|||
req.State.Name = state.Proc
|
||||
for {
|
||||
_, err = c.client.Done(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -140,15 +133,13 @@ func (c *client) Extend(ctx context.Context, id string) (err error) {
|
|||
req.Id = id
|
||||
for {
|
||||
_, err = c.client.Extend(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -166,15 +157,13 @@ func (c *client) Update(ctx context.Context, id string, state State) (err error)
|
|||
req.State.Name = state.Proc
|
||||
for {
|
||||
_, err = c.client.Update(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -192,15 +181,13 @@ func (c *client) Upload(ctx context.Context, id string, file *File) (err error)
|
|||
req.File.Data = file.Data
|
||||
for {
|
||||
_, err = c.client.Upload(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -216,15 +203,13 @@ func (c *client) Log(ctx context.Context, id string, line *Line) (err error) {
|
|||
req.Line.Time = line.Time
|
||||
for {
|
||||
_, err = c.client.Log(ctx, req)
|
||||
//
|
||||
// TODO error type
|
||||
//
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if grpc.Code(err) == codes.Unknown {
|
||||
return err
|
||||
}
|
||||
<-time.After(backoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
54
vendor/vendor.json
vendored
54
vendor/vendor.json
vendored
|
@ -39,80 +39,80 @@
|
|||
{
|
||||
"checksumSHA1": "W3AuK8ocqHwlUajGmQLFvnRhTZE=",
|
||||
"path": "github.com/cncd/pipeline/pipeline",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "rO+djTfB4LrT+FBbpotyUUobOtU=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/backend",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "DzP4c915B+gJTE5RCKQHzxwrUg4=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/backend/docker",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "8Hj/OZnYZyz5N2hqENCTTaGtkNQ=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/frontend",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "9KYIsY8WlWbrRAP7caEpWT70P9c=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "1saqrg1gk6F2N0x2rOCTnSfwBAY=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/compiler",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "Q0GkNUFamVYIA1Fd8r0A5M6Gx54=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/linter",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "kx2sPUIMozPC/g6E4w48h3FfH3k=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/matrix",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "L7Q5qJmPITNmvFEEaj5MPwCWFRk=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/types",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "2/3f3oNmxXy5kcrRLCFa24Oc9O4=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/interrupt",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "uOjTfke7Qxosrivgz/nVTHeIP5g=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/multipart",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "LAuWwrS1JoqxTJnXvVYMAlauyp4=",
|
||||
"checksumSHA1": "ndDase2wF8bWu83aDT8PFxVNSiU=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/rpc",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "WAQJYKWUIFBnL1s8AnY4fePnzJ8=",
|
||||
"path": "github.com/cncd/pipeline/pipeline/rpc/proto",
|
||||
"revision": "9685a43aa7e8f509e9e3ce14db5e014406d0ab8d",
|
||||
"revisionTime": "2017-06-28T17:01:38Z"
|
||||
"revision": "edd4cdaa4846a7bd7778533230597c1b28159a47",
|
||||
"revisionTime": "2017-06-29T21:17:09Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "7Qj1DK0ceAXkYztW0l3+L6sn+V8=",
|
||||
|
|
Loading…
Reference in a new issue