chore(gRPC): fetch new stage data.

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu 2022-09-03 15:59:44 +08:00 committed by Jason Song
parent 6030610c04
commit 631f801aa6
2 changed files with 8 additions and 7 deletions

View File

@ -31,7 +31,7 @@ func New(endpoint, secret string, skipverify bool, opts ...Option) *HTTPClient {
}
client.Client = &http.Client{
Timeout: 5 * time.Second,
Timeout: 1 * time.Minute,
CheckRedirect: func(*http.Request, []*http.Request) error {
return http.ErrUseLastResponse
},

View File

@ -53,7 +53,8 @@ func (p *Poller) Poll(ctx context.Context, n int) error {
return
}
if err := p.poll(ctx, i+1); err != nil {
log.WithError(err).Error("poll error")
log.WithField("thread", i+1).
WithError(err).Error("poll error")
}
}
}
@ -65,10 +66,11 @@ func (p *Poller) Poll(ctx context.Context, n int) error {
}
func (p *Poller) poll(ctx context.Context, thread int) error {
log.WithField("thread", thread).Info("poller: request stage from remote server")
logger := log.WithField("thread", thread)
logger.Info("poller: request stage from remote server")
// TODO: fetch the job from remote server
time.Sleep(time.Second)
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
// request a new build stage for execution from the central
// build server.
@ -79,11 +81,10 @@ func (p *Poller) poll(ctx context.Context, thread int) error {
Type: p.Filter.Type,
})
if err == context.Canceled || err == context.DeadlineExceeded {
log.WithError(err).Trace("poller: no stage returned")
logger.WithError(err).Trace("poller: no stage returned")
return nil
}
if err != nil {
log.WithError(err).Error("poller: cannot request stage")
return err
}