File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,8 @@ func (mod *Module) DiscoverRemoteServices(ctx *astral.Context, target *astral.Id
6060 snapshotCompleted := false
6161 snapshot := make ([]services.ServiceChange , 0 )
6262
63- for {
64- msg , err := ch .Read ()
65- if err != nil {
66- return err
67- }
68-
69- switch m := msg .(type ) {
63+ err = ch .Collect (func (object astral.Object ) error {
64+ switch m := object .(type ) {
7065 case * astral.EOS :
7166 // End-of-snapshot marker.
7267
@@ -105,13 +100,13 @@ func (mod *Module) DiscoverRemoteServices(ctx *astral.Context, target *astral.Id
105100 case * services.ServiceChange :
106101 if ! m .Service .Identity .IsEqual (target ) {
107102 mod .log .Info ("ignoring service from different identity: %v" , m .Service .Identity )
108- continue
103+ return nil
109104 }
110105
111106 if ! snapshotCompleted {
112107 // Still collecting snapshot.
113108 snapshot = append (snapshot , * m )
114- continue
109+ return nil
115110 }
116111
117112 // Live update after snapshot completed.
@@ -131,7 +126,14 @@ func (mod *Module) DiscoverRemoteServices(ctx *astral.Context, target *astral.Id
131126 }
132127
133128 default :
134- mod .log .Info ("unexpected message type: %T" , msg )
129+ mod .log .Info ("unexpected message type: %T" , object )
135130 }
131+
132+ return nil
133+ })
134+ if err != nil {
135+ return err
136136 }
137+
138+ return nil
137139}
You can’t perform that action at this time.
0 commit comments