Skip to content

Commit

Permalink
fix: wait for full startup of data transfer when making client
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Dec 19, 2023
1 parent 5e9f939 commit e7ab797
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions retrievalmarket/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,27 @@ func NewClientWithConfig(cfg *Config) (*Client, error) {
}
}

errCh := make(chan error)
startedCh := make(chan struct{})

mgr.OnReady(func(err error) {
if err != nil {
errCh <- err
return
}
close(startedCh)
})

if err := mgr.Start(context.Background()); err != nil {
return nil, err
}

select {
case <-startedCh:
case err := <-errCh:
return nil, err
}

c := &Client{
host: cfg.Host,
api: cfg.Api,
Expand Down

0 comments on commit e7ab797

Please sign in to comment.