Skip to content

Commit c650572

Browse files
committed
Use anynomous function for channel consumption
1 parent 40c9cf7 commit c650572

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

discovery_server.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ func (d *DiscoveryServer) startSync() {
231231
d.outputError("start_sync", "Discovery already STARTed, cannot START_SYNC")
232232
return
233233
}
234-
d.syncChannel = make(chan interface{}, 10) // buffer up to 10 events
234+
c := make(chan interface{}, 10) // buffer up to 10 events
235+
d.syncChannel = c
235236
if err := d.impl.StartSync(d.syncEvent); err != nil {
236237
d.outputError("start_sync", "Cannot START_SYNC: "+err.Error())
237238
close(d.syncChannel) // do not leak channel...
@@ -240,13 +241,12 @@ func (d *DiscoveryServer) startSync() {
240241
}
241242
d.syncStarted = true
242243
d.outputOk("start_sync")
243-
go d.consumeEvents(d.syncChannel)
244-
}
245244

246-
func (d *DiscoveryServer) consumeEvents(c <-chan interface{}) {
247-
for e := range c {
248-
d.output(e)
249-
}
245+
go func() {
246+
for e := range c {
247+
d.output(e)
248+
}
249+
}()
250250
}
251251

252252
func (d *DiscoveryServer) stop() {

0 commit comments

Comments
 (0)