File tree 2 files changed +9
-9
lines changed 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
10
10
func TestEventLoop_SwapBatches (t * testing.T ) {
11
11
eventLoop := NewEventLoop (nil , zap .New (), nil , nil )
12
12
13
- eventLoop .currentBatch = [] interface {} {
13
+ eventLoop .currentBatch = EventBatch {
14
14
"event0" ,
15
15
"event1" ,
16
16
"event2" ,
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ func (el *EventLoop) Start(ctx context.Context) error {
71
71
}(el .currentBatch )
72
72
}
73
73
74
+ swapAndHandleBatch := func () {
75
+ el .swapBatches ()
76
+ handleBatch ()
77
+ handling = true
78
+ }
79
+
74
80
// Prepare the fist event batch, which includes the UpsertEvents for all relevant cluster resources.
75
81
// This is necessary so that the first time the EventHandler generates NGINX configuration, it derives it from
76
82
// 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 {
116
122
117
123
// If no batch is currently being handled, swap batches and begin handling the batch.
118
124
if ! handling {
119
- el .swapBatches ()
120
-
121
- handleBatch ()
122
- handling = true
125
+ swapAndHandleBatch ()
123
126
}
124
127
case <- handlingDone :
125
128
handling = false
126
129
127
130
// If there's at least one event in the next batch, swap batches and begin handling the batch.
128
131
if len (el .nextBatch ) > 0 {
129
- el .swapBatches ()
130
-
131
- handleBatch ()
132
- handling = true
132
+ swapAndHandleBatch ()
133
133
}
134
134
}
135
135
}
You can’t perform that action at this time.
0 commit comments