File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
1010func TestEventLoop_SwapBatches (t * testing.T ) {
1111 eventLoop := NewEventLoop (nil , zap .New (), nil , nil )
1212
13- eventLoop .currentBatch = [] interface {} {
13+ eventLoop .currentBatch = EventBatch {
1414 "event0" ,
1515 "event1" ,
1616 "event2" ,
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ func (el *EventLoop) Start(ctx context.Context) error {
7171 }(el .currentBatch )
7272 }
7373
74+ swapAndHandleBatch := func () {
75+ el .swapBatches ()
76+ handleBatch ()
77+ handling = true
78+ }
79+
7480 // Prepare the fist event batch, which includes the UpsertEvents for all relevant cluster resources.
7581 // This is necessary so that the first time the EventHandler generates NGINX configuration, it derives it from
7682 // a complete view of the cluster. Otherwise, the handler would generate incomplete configuration, which can lead
@@ -116,20 +122,14 @@ func (el *EventLoop) Start(ctx context.Context) error {
116122
117123 // If no batch is currently being handled, swap batches and begin handling the batch.
118124 if ! handling {
119- el .swapBatches ()
120-
121- handleBatch ()
122- handling = true
125+ swapAndHandleBatch ()
123126 }
124127 case <- handlingDone :
125128 handling = false
126129
127130 // If there's at least one event in the next batch, swap batches and begin handling the batch.
128131 if len (el .nextBatch ) > 0 {
129- el .swapBatches ()
130-
131- handleBatch ()
132- handling = true
132+ swapAndHandleBatch ()
133133 }
134134 }
135135 }
You can’t perform that action at this time.
0 commit comments