Closed guicassolato closed 2 months ago
Proposal for an execution plan, based on the current code:
Runnable
interface: { Run(stopCh <-chan struct{}) }
informers
of the controller to be a list of generic runnables
WithInformer
to WithRunnable
InformerBuilder(builder)
cache.SharedInformer
that adds incremental changes directly to the cache (default informer builder)ListFunc
to a slice of state reconciler ListFuncs
of the controllercontroller.For
to controller.Watch
ManagedBy(manager)
Reconciler
interface
ListFuncs
registered with the controllercontroller.Start()
:
controller.New("gatewayapi", c.manager, controller.Options{Reconciler: c})
c.manager.Start()
CallbackFunc
as ReconcileFunc
ReconcileFunc
to receive a list of ResourceEvents
WithCallback
to WithReconciler(ReconcileFunc)
if snapshot, ok := <-subscription; ok {
events := lo.Map(snapshot.Updates, …)
topology := c.topology.Build(snapshot.State)
reconcileFunc(ctx, events, topology)
}
Enhance the
controller
package with optional state-of-world reconciliation:There are several good reasons to use controller-runtime, especially in situations where the event stream is unreliable (e.g. event loss; despite periodic resyncs implemented by the informers.) These reasons include:
Traps to avoid / recommendation: