feat(runner): Added waiting for a job arrival in the one-job command.

This commit is contained in:
Richard Robert Reitz 2025-10-29 11:12:12 +01:00
parent 10a9ab9001
commit 88e6654a6c

View file

@ -36,11 +36,20 @@ func NewJob(cfg *config.Config, client client.Client, runner run.RunnerInterface
}
func (j *Job) Run(ctx context.Context) error {
log.Info("Polling for a job...")
for {
task, ok := j.fetchTask(ctx)
if !ok {
return fmt.Errorf("could not fetch task")
}
if ok {
return j.runTaskWithRecover(ctx, task)
}
// No task available, continue polling
select {
case <-ctx.Done():
return ctx.Err()
default:
// Continue to next iteration
}
}
}
func (j *Job) runTaskWithRecover(ctx context.Context, task *runnerv1.Task) error {