Skip to content

Commit

Permalink
Replaced DiscoveryManager.Watch with equivalent gRPC BoardListWatch call
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Sep 22, 2023
1 parent d1929de commit cbf2de2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions internal/cli/arguments/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,22 @@ func (p *Port) GetPort(instance *rpc.Instance, defaultAddress, defaultProtocol s
}
logrus.WithField("port", address).Tracef("Upload port")

dm := pme.DiscoveryManager()
watcher, err := dm.Watch()
watcher, cancel, err := board.Watch(&rpc.BoardListWatchRequest{Instance: instance})
if err != nil {
return nil, err
}
defer watcher.Close()
defer cancel()

deadline := time.After(p.timeout.Get())
for {
select {
case portEvent := <-watcher.Feed():
if portEvent.Type != "add" {
case portEvent := <-watcher:
if portEvent.GetEventType() != "add" {
continue
}
port := portEvent.Port
if (protocol == "" || protocol == port.Protocol) && address == port.Address {
return port.ToRPC(), nil
port := portEvent.GetPort().GetPort()
if (protocol == "" || protocol == port.GetProtocol()) && address == port.GetAddress() {
return port, nil
}

case <-deadline:
Expand Down

0 comments on commit cbf2de2

Please sign in to comment.