mirror of
https://gitea.com/gitea/act_runner.git
synced 2025-02-06 18:04:45 +01:00
use version
This commit is contained in:
parent
cef297af9c
commit
06d40a2c3c
@ -24,8 +24,8 @@ type Poller struct {
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// taskIndex used to store the index of the last task fetched from the Gitea.
|
||||
var taskIndex int64
|
||||
// taskVersion used to store the version of the last task fetched from the Gitea.
|
||||
var taskVersion int64
|
||||
|
||||
func New(cfg *config.Config, client client.Client, runner *run.Runner) *Poller {
|
||||
return &Poller{
|
||||
@ -69,7 +69,7 @@ func (p *Poller) fetchTask(ctx context.Context) (*runnerv1.Task, bool) {
|
||||
defer cancel()
|
||||
|
||||
resp, err := p.client.FetchTask(reqCtx, connect.NewRequest(&runnerv1.FetchTaskRequest{
|
||||
TaskIndex: taskIndex,
|
||||
TaskVersion: taskVersion,
|
||||
}))
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
err = nil
|
||||
@ -83,14 +83,14 @@ func (p *Poller) fetchTask(ctx context.Context) (*runnerv1.Task, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
taskIndex = resp.Msg.TaskIndex
|
||||
taskVersion = resp.Msg.TaskVersion
|
||||
|
||||
if resp.Msg.Task == nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// got a task, use 0 index to focre query db in next request.
|
||||
taskIndex = 0
|
||||
// got a task, set `taskVersion` to zero to focre query db in next request.
|
||||
taskVersion = 0
|
||||
|
||||
return resp.Msg.Task, true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user