@@ -55,7 +55,7 @@ var _ = Describe("runnables", func() {
55
55
})
56
56
57
57
It ("should add WarmupRunnable to the Warmup and LeaderElection group" , func () {
58
- warmupRunnable := WarmupRunnableFunc {
58
+ warmupRunnable := warmupRunnableFunc {
59
59
RunFunc : func (c context.Context ) error {
60
60
<- c .Done ()
61
61
return nil
@@ -72,7 +72,7 @@ var _ = Describe("runnables", func() {
72
72
})
73
73
74
74
It ("should add WarmupRunnable that doesn't needs leader election to warmup group only" , func () {
75
- warmupRunnable := CombinedRunnable {
75
+ warmupRunnable := combinedRunnable {
76
76
RunFunc : func (c context.Context ) error {
77
77
<- c .Done ()
78
78
return nil
@@ -93,7 +93,7 @@ var _ = Describe("runnables", func() {
93
93
})
94
94
95
95
It ("should add WarmupRunnable that needs leader election to Warmup and LeaderElection group, not Others" , func () {
96
- warmupRunnable := CombinedRunnable {
96
+ warmupRunnable := combinedRunnable {
97
97
RunFunc : func (c context.Context ) error {
98
98
<- c .Done ()
99
99
return nil
@@ -117,7 +117,7 @@ var _ = Describe("runnables", func() {
117
117
It ("should execute the Warmup function when Warmup group is started" , func () {
118
118
var warmupExecuted atomic.Bool
119
119
120
- warmupRunnable := WarmupRunnableFunc {
120
+ warmupRunnable := warmupRunnableFunc {
121
121
RunFunc : func (c context.Context ) error {
122
122
<- c .Done ()
123
123
return nil
@@ -144,7 +144,7 @@ var _ = Describe("runnables", func() {
144
144
It ("should propagate errors from Warmup function to error channel" , func () {
145
145
expectedErr := fmt .Errorf ("expected warmup error" )
146
146
147
- warmupRunnable := WarmupRunnableFunc {
147
+ warmupRunnable := warmupRunnableFunc {
148
148
RunFunc : func (c context.Context ) error {
149
149
<- c .Done ()
150
150
return nil
@@ -349,51 +349,63 @@ var _ = Describe("runnableGroup", func() {
349
349
})
350
350
})
351
351
352
- // LeaderElectionRunnableFunc is a helper struct that implements LeaderElectionRunnable
352
+ var _ LeaderElectionRunnable = & leaderElectionRunnableFunc {}
353
+
354
+ // leaderElectionRunnableFunc is a helper struct that implements LeaderElectionRunnable
353
355
// for testing purposes.
354
- type LeaderElectionRunnableFunc struct {
356
+ type leaderElectionRunnableFunc struct {
355
357
RunFunc func (context.Context ) error
356
358
NeedLeaderElectionFunc func () bool
357
359
}
358
360
359
- func (r LeaderElectionRunnableFunc ) Start (ctx context.Context ) error {
361
+ func (r leaderElectionRunnableFunc ) Start (ctx context.Context ) error {
360
362
return r .RunFunc (ctx )
361
363
}
362
364
363
- func (r LeaderElectionRunnableFunc ) NeedLeaderElection () bool {
365
+ func (r leaderElectionRunnableFunc ) NeedLeaderElection () bool {
364
366
return r .NeedLeaderElectionFunc ()
365
367
}
366
368
367
- // WarmupRunnableFunc is a helper struct that implements WarmupRunnable
369
+ var _ WarmupRunnable = & warmupRunnableFunc {}
370
+
371
+ // warmupRunnableFunc is a helper struct that implements WarmupRunnable
368
372
// for testing purposes.
369
- type WarmupRunnableFunc struct {
373
+ type warmupRunnableFunc struct {
370
374
RunFunc func (context.Context ) error
371
375
WarmupFunc func (context.Context ) error
372
376
}
373
377
374
- func (r WarmupRunnableFunc ) Start (ctx context.Context ) error {
378
+ func (r warmupRunnableFunc ) Start (ctx context.Context ) error {
375
379
return r .RunFunc (ctx )
376
380
}
377
381
378
- func (r WarmupRunnableFunc ) Warmup (ctx context.Context ) error {
382
+ func (r warmupRunnableFunc ) Warmup (ctx context.Context ) error {
379
383
return r .WarmupFunc (ctx )
380
384
}
381
385
382
- // CombinedRunnable implements both WarmupRunnable and LeaderElectionRunnable
383
- type CombinedRunnable struct {
386
+ func (r warmupRunnableFunc ) WaitForWarmupComplete (ctx context.Context ) bool {
387
+ return true
388
+ }
389
+
390
+ // combinedRunnable implements both WarmupRunnable and LeaderElectionRunnable
391
+ type combinedRunnable struct {
384
392
RunFunc func (context.Context ) error
385
393
WarmupFunc func (context.Context ) error
386
394
NeedLeaderElectionFunc func () bool
387
395
}
388
396
389
- func (r CombinedRunnable ) Start (ctx context.Context ) error {
397
+ func (r combinedRunnable ) Start (ctx context.Context ) error {
390
398
return r .RunFunc (ctx )
391
399
}
392
400
393
- func (r CombinedRunnable ) Warmup (ctx context.Context ) error {
401
+ func (r combinedRunnable ) Warmup (ctx context.Context ) error {
394
402
return r .WarmupFunc (ctx )
395
403
}
396
404
397
- func (r CombinedRunnable ) NeedLeaderElection () bool {
405
+ func (r combinedRunnable ) WaitForWarmupComplete (ctx context.Context ) bool {
406
+ return true
407
+ }
408
+
409
+ func (r combinedRunnable ) NeedLeaderElection () bool {
398
410
return r .NeedLeaderElectionFunc ()
399
411
}
0 commit comments