@@ -57,7 +57,6 @@ type PluggableDiscovery struct {
57
57
incomingMessagesError error
58
58
state int
59
59
eventChan chan <- * Event
60
- cachedPorts map [string ]* Port
61
60
}
62
61
63
62
type discoveryMessage struct {
@@ -132,7 +131,6 @@ func New(id string, args ...string) *PluggableDiscovery {
132
131
id : id ,
133
132
processArgs : args ,
134
133
state : Dead ,
135
- cachedPorts : map [string ]* Port {},
136
134
}
137
135
}
138
136
@@ -177,7 +175,6 @@ func (disc *PluggableDiscovery) jsonDecodeLoop(in io.Reader, outChan chan<- *dis
177
175
return
178
176
}
179
177
disc .statusMutex .Lock ()
180
- disc .cachedPorts [msg .Port .Address + "|" + msg .Port .Protocol ] = msg .Port
181
178
if disc .eventChan != nil {
182
179
disc .eventChan <- & Event {"add" , msg .Port , disc .GetID ()}
183
180
}
@@ -188,7 +185,6 @@ func (disc *PluggableDiscovery) jsonDecodeLoop(in io.Reader, outChan chan<- *dis
188
185
return
189
186
}
190
187
disc .statusMutex .Lock ()
191
- delete (disc .cachedPorts , msg .Port .Address + "|" + msg .Port .Protocol )
192
188
if disc .eventChan != nil {
193
189
disc .eventChan <- & Event {"remove" , msg .Port , disc .GetID ()}
194
190
}
@@ -371,12 +367,6 @@ func (disc *PluggableDiscovery) Stop() error {
371
367
372
368
func (disc * PluggableDiscovery ) stopSync () {
373
369
if disc .eventChan != nil {
374
- // When stopping sync send a batch of "remove" events for
375
- // all the active ports.
376
- for _ , port := range disc .cachedPorts {
377
- disc .eventChan <- & Event {"remove" , port , disc .GetID ()}
378
- }
379
- disc .cachedPorts = map [string ]* Port {}
380
370
disc .eventChan <- & Event {"stop" , nil , disc .GetID ()}
381
371
close (disc .eventChan )
382
372
disc .eventChan = nil
@@ -440,16 +430,3 @@ func (disc *PluggableDiscovery) StartSync(size int) (<-chan *Event, error) {
440
430
disc .eventChan = c
441
431
return c , nil
442
432
}
443
-
444
- // ListCachedPorts returns a list of the available ports. The list is a cache of all the
445
- // add/remove events happened from the StartSync call and it will not consume any
446
- // resource from the underliying discovery.
447
- func (disc * PluggableDiscovery ) ListCachedPorts () []* Port {
448
- disc .statusMutex .Lock ()
449
- defer disc .statusMutex .Unlock ()
450
- res := []* Port {}
451
- for _ , port := range disc .cachedPorts {
452
- res = append (res , port )
453
- }
454
- return res
455
- }
0 commit comments