Documentation ¶
Overview ¶
The reflector package provides a set of utilities to reflect external data into a statedb table.
Index ¶
Constants ¶
const ( // DefaultBufferSize is the maximum number of objects to commit to the table in one write transaction. DefaultBufferSize = 64 // DefaultBufferWaitTime is the amount of time to wait to fill the buffer before committing objects. DefaultBufferWaitTime = 50 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
func KubernetesCell ¶
KubernetesCell constructs a cell that constructs a Kubernetes source and adds it to the application lifecycle. If you need dynamic control over if and when to start or stop the reflection, use Kubernetes and call Reflector.Start and Reflector.Stop manually.
For dependencies needed by this cell see KubernetesParams.
Types ¶
type KubernetesConfig ¶
type KubernetesConfig[Obj any] struct { BufferSize int // Maximum number of objects to commit in one transaction. Uses default if left zero. BufferWaitTime time.Duration // The amount of time to wait for the buffer to fill. Uses default if left zero. ListerWatcher cache.ListerWatcher // The ListerWatcher to use to retrieve the objects Transform TransformFunc[Obj] // Optional function to transform the objects given by the ListerWatcher QueryAll QueryAllFunc[Obj] // Optional function to query all objects Table statedb.RWTable[Obj] // The table to populate }
type KubernetesParams ¶
type QueryAllFunc ¶
QueryAllFunc is an optional function to give to the Kubernetes reflector to query all objects in the table that are managed by the reflector. It is used to delete all objects when the underlying cache.Reflector needs to Replace() all items for a resync.
type Reflector ¶
type Reflector[Obj any] interface { cell.HookInterface // Can be started and stopped. }
Reflector reflects external data into a statedb table
func Kubernetes ¶
func Kubernetes[Obj any](p KubernetesParams[Obj]) Reflector[Obj]
Kubernetes synchronizes statedb table with an external Kubernetes resource. Returns a 'Reflector' for starting and stopping it. If the source can be started unconditionally, consider using KubernetesCell instead.
type TransformFunc ¶
TransformFunc is an optional function to give to the Kubernetes reflector to transform the object returned by the ListerWatcher to the desired target object. If the function returns false the object is silently skipped.