Improve solver channel management according to @aluzzardi comments
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
@@ -170,26 +170,17 @@ func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.
|
||||
go catchOutput(buildCh)
|
||||
|
||||
resp, err := c.c.Build(ctx, opts, "", func(ctx context.Context, gw bkgw.Client) (*bkgw.Result, error) {
|
||||
eventsWg := sync.WaitGroup{}
|
||||
closeCh := make(chan *bk.SolveStatus)
|
||||
s := solver.New(solver.Opts{
|
||||
Control: c.c,
|
||||
Gateway: gw,
|
||||
Events: eventsCh,
|
||||
Auth: auth,
|
||||
Secrets: secrets,
|
||||
NoCache: c.cfg.NoCache,
|
||||
})
|
||||
|
||||
// Close events channel
|
||||
defer func() {
|
||||
close(closeCh)
|
||||
eventsWg.Wait()
|
||||
close(eventsCh)
|
||||
}()
|
||||
|
||||
s := solver.New(solver.Opts{
|
||||
Control: c.c,
|
||||
Gateway: gw,
|
||||
Events: eventsCh,
|
||||
EventsWg: &eventsWg,
|
||||
CloseEvent: closeCh,
|
||||
Auth: auth,
|
||||
Secrets: secrets,
|
||||
NoCache: c.cfg.NoCache,
|
||||
})
|
||||
defer s.Stop()
|
||||
|
||||
// Compute output overlay
|
||||
if fn != nil {
|
||||
|
Reference in New Issue
Block a user