Skip to content

Commit

Permalink
📖 Mark Typed Handlers as experimental
Browse files Browse the repository at this point in the history
We will need to break them if we want to introduce a generic reconciler
with a generic workqueue so mark them as experimental.
  • Loading branch information
alvaroaleman committed Apr 23, 2024
1 parent b74908f commit b35cd6b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/handler/enqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type EnqueueRequestForObject = TypedEnqueueRequestForObject[client.Object]
// TypedEnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event.
// (e.g. the created / deleted / updated objects Name and Namespace). handler.TypedEnqueueRequestForObject is used by almost all
// Controllers that have associated Resources (e.g. CRDs) to reconcile the associated Resource.
//
// TypedEnqueueRequestForObject is experimental and subject to future change.
type TypedEnqueueRequestForObject[T client.Object] struct{}

// Create implements EventHandler.
Expand Down
4 changes: 4 additions & 0 deletions pkg/handler/enqueue_mapped.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type MapFunc = TypedMapFunc[client.Object]

// TypedMapFunc is the signature required for enqueueing requests from a generic function.
// This type is usually used with EnqueueRequestsFromTypedMapFunc when registering an event handler.
//
// TypedMapFunc is experimental and subject to future change.
type TypedMapFunc[T any] func(context.Context, T) []reconcile.Request

// EnqueueRequestsFromMapFunc enqueues Requests by running a transformation function that outputs a collection
Expand All @@ -57,6 +59,8 @@ func EnqueueRequestsFromMapFunc(fn MapFunc) EventHandler {
//
// For TypedUpdateEvents which contain both a new and old object, the transformation function is run on both
// objects and both sets of Requests are enqueue.
//
// TypedEnqueueRequestsFromMapFunc is experimental and subject to future change.
func TypedEnqueueRequestsFromMapFunc[T any](fn TypedMapFunc[T]) TypedEventHandler[T] {
return &enqueueRequestsFromMapFunc[T]{
toRequests: fn,
Expand Down
2 changes: 2 additions & 0 deletions pkg/handler/enqueue_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func EnqueueRequestForOwner(scheme *runtime.Scheme, mapper meta.RESTMapper, owne
// - a source.Kind Source with Type of Pod.
//
// - a handler.typedEnqueueRequestForOwner EventHandler with an OwnerType of ReplicaSet and OnlyControllerOwner set to true.
//
// TypedEnqueueRequestForOwner is experimental and subject to future change.
func TypedEnqueueRequestForOwner[T client.Object](scheme *runtime.Scheme, mapper meta.RESTMapper, ownerType client.Object, opts ...OwnerOption) TypedEventHandler[T] {
e := &enqueueRequestForOwner[T]{
ownerType: ownerType,
Expand Down
4 changes: 4 additions & 0 deletions pkg/handler/eventhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type EventHandler TypedEventHandler[client.Object]
//
// Unless you are implementing your own TypedEventHandler, you can ignore the functions on the TypedEventHandler interface.
// Most users shouldn't need to implement their own TypedEventHandler.
//
// TypedEventHandler is experimental and subject to future change.
type TypedEventHandler[T any] interface {
// Create is called in response to a create event - e.g. Pod Creation.
Create(context.Context, event.TypedCreateEvent[T], workqueue.RateLimitingInterface)
Expand All @@ -83,6 +85,8 @@ var _ EventHandler = Funcs{}
type Funcs = TypedFuncs[client.Object]

// TypedFuncs implements eventhandler.
//
// TypedFuncs is experimental and subject to future change.
type TypedFuncs[T any] struct {
// Create is called in response to an add event. Defaults to no-op.
// RateLimitingInterface is used to enqueue reconcile.Requests.
Expand Down

0 comments on commit b35cd6b

Please sign in to comment.