Skip to content

Commit 5499aa8

Browse files
committed
fix gocyclo
1 parent e844cac commit 5499aa8

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

pkg/controller/source/source.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,7 @@ func (cs *ChannelSource) Start(
110110

111111
cs.once.Do(func() {
112112
// Distribute GenericEvents to all EventHandler / Queue pairs Watching this source
113-
go func() {
114-
for {
115-
select {
116-
case <-cs.stop:
117-
// Close destination channels
118-
cs.doStop()
119-
return
120-
case evt := <-cs.Source:
121-
cs.distribute(evt)
122-
}
123-
}
124-
}()
113+
go cs.syncLoop()
125114
})
126115

127116
dst := make(chan event.GenericEvent, cs.DestBufferSize)
@@ -172,6 +161,19 @@ func (cs *ChannelSource) distribute(evt event.GenericEvent) {
172161
}
173162
}
174163

164+
func (cs *ChannelSource) syncLoop() {
165+
for {
166+
select {
167+
case <-cs.stop:
168+
// Close destination channels
169+
cs.doStop()
170+
return
171+
case evt := <-cs.Source:
172+
cs.distribute(evt)
173+
}
174+
}
175+
}
176+
175177
// KindSource is used to provide a source of events originating inside the cluster from Watches (eh.g. Pod Create)
176178
type KindSource struct {
177179
// Type is the type of object to watch. e.g. &v1.Pod{}

0 commit comments

Comments
 (0)