Download this file
| 1 | package runner |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/runnerproto" |
| 5 | "context" |
| 6 | ) |
| 7 | |
| 8 | func (s *Supervisor) uploadDirectEvent(ctx context.Context, r *attemptState, e Event) error { |
| 9 | q := runnerproto.RunnerRequest{Version: 2, AssignmentID: e.AssignmentID, Scope: e.Scope, Handle: e.Handle, RequestID: e.ID, ActionID: e.ActionID} |
| 10 | q.Event, _ = runnerproto.Marshal(e) |
| 11 | return s.api.Call(ctx, "events", q, nil) |
| 12 | } |
| 13 | func finishDirectStream(ctx context.Context, close func() error, done chan error, drain func(context.Context) error) error { |
| 14 | if err := close(); err != nil { |
| 15 | return err |
| 16 | } |
| 17 | select { |
| 18 | case <-ctx.Done(): |
| 19 | return ctx.Err() |
| 20 | case err := <-done: |
| 21 | done <- err |
| 22 | if err != nil { |
| 23 | return err |
| 24 | } |
| 25 | } |
| 26 | return drain(ctx) |
| 27 | } |
| 28 | |