fix: 隔离 Pod 与 VM 并发容量
This commit is contained in:
@@ -26,7 +26,6 @@ type PollerConfig struct {
|
||||
type Poller struct {
|
||||
Client PollClient
|
||||
Scheduler *Scheduler
|
||||
Gate *SingleFlightGate
|
||||
Config PollerConfig
|
||||
OnError func(error)
|
||||
}
|
||||
@@ -51,14 +50,7 @@ func (p Poller) Run(ctx context.Context) error {
|
||||
errorBackoff = 5 * time.Second
|
||||
}
|
||||
var tasksVersion int64
|
||||
haveLease := false
|
||||
for {
|
||||
if p.Gate != nil && !haveLease {
|
||||
if err := p.Gate.Acquire(ctx); err != nil {
|
||||
return nil
|
||||
}
|
||||
haveLease = true
|
||||
}
|
||||
response, err := p.Client.FetchTask(ctx, tasksVersion)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
@@ -80,10 +72,6 @@ func (p Poller) Run(ctx context.Context) error {
|
||||
tasksVersion = response.GetTasksVersion()
|
||||
task := response.GetTask()
|
||||
if task == nil {
|
||||
if p.Gate != nil {
|
||||
p.Gate.Release()
|
||||
haveLease = false
|
||||
}
|
||||
if !wait(ctx, emptyBackoff) {
|
||||
return nil
|
||||
}
|
||||
@@ -91,7 +79,6 @@ func (p Poller) Run(ctx context.Context) error {
|
||||
}
|
||||
for {
|
||||
if err := p.Scheduler.Run(ctx, task); err == nil {
|
||||
haveLease = false
|
||||
break
|
||||
} else {
|
||||
if ctx.Err() != nil {
|
||||
|
||||
Reference in New Issue
Block a user