Documentation
¶
Index ¶
- func WorkerId(ctx context.Context) string
- type Controller
- type ControllerEntity
- type ControllerManager
- type DeletingReconcileController
- type EntityAccessClient
- type Event
- type EventType
- type GenericController
- type HandlerFunc
- type ReconcileController
- type ReconcileControllerI
- type UpdatingController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Controller ¶
Controller processes entities of a specific kind
type ControllerEntity ¶
type ControllerEntity interface {
Decode(getter entity.AttrGetter)
Encode() []entity.Attr
}
type ControllerManager ¶
type ControllerManager struct {
// contains filtered or unexported fields
}
ControllerManager manages multiple controllers
func NewControllerManager ¶
func NewControllerManager() *ControllerManager
NewControllerManager creates a new controller manager
func (*ControllerManager) AddController ¶
func (m *ControllerManager) AddController(controller Controller)
AddController adds a controller to the manager
type DeletingReconcileController ¶
DeletingReconcileController is an optional interface that reconcile controllers can implement to handle deletion of their managed entities.
type EntityAccessClient ¶
type EntityAccessClient interface {
// Get returns a single entity by its ID
Get(ctx context.Context, id string) (*entityserver_v1alpha.EntityAccessClientGetResults, error)
// List returns all entities matching the given index
List(ctx context.Context, index entity.Attr) (*entityserver_v1alpha.EntityAccessClientListResults, error)
// WatchIndex watches for changes to entities matching the given index
// and sends updates through the provided sender
WatchIndex(ctx context.Context, index entity.Attr, sender stream.SendStream[*entityserver_v1alpha.EntityOp]) error
}
EntityAccessClient defines the interface for interacting with the entity server
type Event ¶
type Event struct {
Type EventType
Id entity.Id
Entity *entity.Entity // The entity that was changed
Rev, PrevRev int64 // Revision and previous revision for the entity
}
Event represents a change to an entity
type EventType ¶
type EventType string
EventType represents the type of event that occurred on an entity
type GenericController ¶
type HandlerFunc ¶
HandlerFunc is a function that processes an entity
func AdaptController ¶
func AdaptController[ T any, P interface { *T ControllerEntity }, C GenericController[P], ](cont C) HandlerFunc
func AdaptReconcileController ¶
func AdaptReconcileController[ T any, P interface { *T ControllerEntity }, C ReconcileControllerI[P], ](cont C) HandlerFunc
AdaptReconcileController adapts a ReconcileControllerI into a HandlerFunc. It calls Reconcile() for both Add and Update events. If the controller implements DeletingReconcileController, Delete() is called for Delete events.
type ReconcileController ¶
ReconcileController implements the Controller interface
func NewReconcileController ¶
func NewReconcileController(name string, log *slog.Logger, index entity.Attr, esc *entityserver_v1alpha.EntityAccessClient, handler HandlerFunc, resyncPeriod time.Duration, workers int) *ReconcileController
NewReconcileController creates a new controller
func (*ReconcileController) Enqueue ¶
func (c *ReconcileController) Enqueue(event Event)
Enqueue adds an event to the work queue for processing
func (*ReconcileController) SetPeriodic ¶
SetPeriodic sets the periodic callback function
type ReconcileControllerI ¶
type ReconcileControllerI[P ControllerEntity] interface { Init(context.Context) error Reconcile(ctx context.Context, obj P, meta *entity.Meta) error }
ReconcileControllerI is for controllers that maintain aggregate state across multiple entities. Unlike GenericController which maps 1:1 between an entity and a resource, ReconcileControllerI handles controllers where one entity drives reconciliation of N resources.
type UpdatingController ¶
type UpdatingController[P ControllerEntity] interface { Update(ctx context.Context, obj P, meta *entity.Meta) error }
UpdatingController is an optional interface that controllers can implement to handle updates differently from creates