@@ -59,6 +59,16 @@ type Reconciler struct {
59
59
controllerName string
60
60
}
61
61
62
+ type ReconcilerOption func (* Reconciler )
63
+
64
+ // WithTrafficDistributionEnabled controls whether the Reconciler considers the
65
+ // `trafficDistribution` field while reconciling EndpointSlices.
66
+ func WithTrafficDistributionEnabled (enabled bool ) ReconcilerOption {
67
+ return func (r * Reconciler ) {
68
+ r .trafficDistributionEnabled = enabled
69
+ }
70
+ }
71
+
62
72
// endpointMeta includes the attributes we group slices on, this type helps with
63
73
// that logic in Reconciler
64
74
type endpointMeta struct {
@@ -327,18 +337,21 @@ func (r *Reconciler) reconcileByAddressType(logger klog.Logger, service *corev1.
327
337
328
338
}
329
339
330
- func NewReconciler (client clientset.Interface , nodeLister corelisters.NodeLister , maxEndpointsPerSlice int32 , endpointSliceTracker * endpointsliceutil.EndpointSliceTracker , topologyCache * topologycache.TopologyCache , trafficDistributionEnabled bool , eventRecorder record.EventRecorder , controllerName string ) * Reconciler {
331
- return & Reconciler {
332
- client : client ,
333
- nodeLister : nodeLister ,
334
- maxEndpointsPerSlice : maxEndpointsPerSlice ,
335
- endpointSliceTracker : endpointSliceTracker ,
336
- metricsCache : metrics .NewCache (maxEndpointsPerSlice ),
337
- topologyCache : topologyCache ,
338
- trafficDistributionEnabled : trafficDistributionEnabled ,
339
- eventRecorder : eventRecorder ,
340
- controllerName : controllerName ,
340
+ func NewReconciler (client clientset.Interface , nodeLister corelisters.NodeLister , maxEndpointsPerSlice int32 , endpointSliceTracker * endpointsliceutil.EndpointSliceTracker , topologyCache * topologycache.TopologyCache , eventRecorder record.EventRecorder , controllerName string , options ... ReconcilerOption ) * Reconciler {
341
+ r := & Reconciler {
342
+ client : client ,
343
+ nodeLister : nodeLister ,
344
+ maxEndpointsPerSlice : maxEndpointsPerSlice ,
345
+ endpointSliceTracker : endpointSliceTracker ,
346
+ metricsCache : metrics .NewCache (maxEndpointsPerSlice ),
347
+ topologyCache : topologyCache ,
348
+ eventRecorder : eventRecorder ,
349
+ controllerName : controllerName ,
350
+ }
351
+ for _ , option := range options {
352
+ option (r )
341
353
}
354
+ return r
342
355
}
343
356
344
357
// placeholderSliceCompare is a conversion func for comparing two placeholder endpoint slices.
0 commit comments