mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: cleanup of unused/global constants in lb agent (#1020)
Moved retry interval as placer member variable for time-being.
This commit is contained in:
@@ -7,18 +7,21 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/fnproject/fn/api/common"
|
||||
"github.com/fnproject/fn/api/models"
|
||||
|
||||
"github.com/dchest/siphash"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type chPlacer struct{}
|
||||
type chPlacer struct {
|
||||
rrInterval time.Duration
|
||||
}
|
||||
|
||||
func NewCHPlacer() Placer {
|
||||
logrus.Info("Creating new CH runnerpool placer")
|
||||
return &chPlacer{}
|
||||
return &chPlacer{
|
||||
rrInterval: 10 * time.Millisecond,
|
||||
}
|
||||
}
|
||||
|
||||
// This borrows the CH placement algorithm from the original FNLB.
|
||||
@@ -62,18 +65,13 @@ func (p *chPlacer) PlaceCall(rp RunnerPool, ctx context.Context, call RunnerCall
|
||||
}
|
||||
}
|
||||
|
||||
remaining := call.LbDeadline().Sub(time.Now())
|
||||
if remaining <= 0 {
|
||||
return models.ErrCallTimeoutServerBusy
|
||||
}
|
||||
|
||||
// backoff
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return models.ErrCallTimeoutServerBusy
|
||||
case <-timeout:
|
||||
return models.ErrCallTimeoutServerBusy
|
||||
case <-time.After(common.MinDuration(retryWaitInterval, remaining)):
|
||||
case <-time.After(p.rrInterval):
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user