chore(gRPC): add request interface client

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu
2022-09-01 15:09:22 +08:00
committed by Jason Song
parent 449388f3ab
commit f2fb8798fa
6 changed files with 58 additions and 21 deletions

View File

@ -23,25 +23,16 @@ type Runner struct {
}
// Run runs the pipeline stage.
func (s *Runner) Run(ctx context.Context, runner *runnerv1.Runner) error {
func (s *Runner) Run(ctx context.Context, stage *runnerv1.Stage) error {
l := logrus.
WithField("runner.UUID", runner.Uuid).
WithField("runner.token", runner.Token)
l.Info("request a new task")
// TODO: get new task
return s.run(ctx, runner)
}
func (s *Runner) run(ctx context.Context, runner *runnerv1.Runner) error {
l := logrus.
WithField("runner.Uuid", runner.Uuid)
WithField("runner.ID", stage.Id).
WithField("runner.BuildID", stage.BuildId)
l.Info("start running pipeline")
// TODO: docker runner with stage data
// task.Run is blocking, so we need to use goroutine to run it in background
// return task metadata and status to the server
task := NewTask()
return task.Run(ctx)
}