Skip to content

Commit 39e5651

Browse files
committed
Replaced DiscoveryManager.Watch with equivalent gRPC BoardListWatch call
1 parent acadc5c commit 39e5651

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Diff for: internal/cli/arguments/port.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package arguments
1717

1818
import (
19+
"context"
1920
"fmt"
2021
"time"
2122

@@ -87,23 +88,23 @@ func (p *Port) GetPort(instance *rpc.Instance, defaultAddress, defaultProtocol s
8788
}
8889
logrus.WithField("port", address).Tracef("Upload port")
8990

90-
dm := pme.DiscoveryManager()
91-
watcher, err := dm.Watch()
91+
ctx, cancel := context.WithCancel(context.Background())
92+
defer cancel()
93+
watcher, err := board.Watch(ctx, &rpc.BoardListWatchRequest{Instance: instance})
9294
if err != nil {
9395
return nil, err
9496
}
95-
defer watcher.Close()
9697

9798
deadline := time.After(p.timeout.Get())
9899
for {
99100
select {
100-
case portEvent := <-watcher.Feed():
101-
if portEvent.Type != "add" {
101+
case portEvent := <-watcher:
102+
if portEvent.GetEventType() != "add" {
102103
continue
103104
}
104-
port := portEvent.Port
105-
if (protocol == "" || protocol == port.Protocol) && address == port.Address {
106-
return port.ToRPC(), nil
105+
port := portEvent.GetPort().GetPort()
106+
if (protocol == "" || protocol == port.GetProtocol()) && address == port.GetAddress() {
107+
return port, nil
107108
}
108109

109110
case <-deadline:

0 commit comments

Comments
 (0)