router

package
v0.0.0-...-5669fb0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2024 License: Apache-2.0 Imports: 32 Imported by: 21

Documentation

Index

Constants

View Source
const (
	TriggerPrefix = "_t "
	ReplayPrefix  = "_r "
)

Variables

This section is empty.

Functions

func GetOrCreate

func GetOrCreate(ctx context.Context, client kclient.Client, obj kclient.Object, prepare func() error) error

func Key

func Key(namespace, name string) kclient.ObjectKey

func StatusChanged

func StatusChanged(unmodified, newObj runtime.Object) bool

Types

type AddToSchemer

type AddToSchemer func(s *runtime.Scheme) error

type ErrorHandler

type ErrorHandler func(req Request, resp Response, err error) error

ErrorHandler is a user defined function to handle an error. If the ErrorHandler returns nil this req is considered handled and will not be re-enqueued. If a non-nil resp is return this key will be re-enqueued. ErrorHandler will be call for nil errors also so That the ErrorHandler can possibly clear a previous error state.

type ErrorPrefix

type ErrorPrefix struct {
	Next Handler
	// contains filtered or unexported fields
}

func (ErrorPrefix) Handle

func (e ErrorPrefix) Handle(req Request, resp Response) error

type FieldSelectorFilter

type FieldSelectorFilter struct {
	Next          Handler
	FieldSelector fields.Selector
}

func (FieldSelectorFilter) Handle

func (s FieldSelectorFilter) Handle(req Request, resp Response) error

type FinalizerHandler

type FinalizerHandler struct {
	FinalizerID string
	Next        Handler
}

func (FinalizerHandler) Handle

func (f FinalizerHandler) Handle(req Request, resp Response) error

type Handler

type Handler interface {
	Handle(req Request, resp Response) error
}

type HandlerFunc

type HandlerFunc func(req Request, resp Response) error

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(req Request, resp Response) error

type HandlerSet

type HandlerSet struct {
	// contains filtered or unexported fields
}

func NewHandlerSet

func NewHandlerSet(name string, scheme *runtime.Scheme, backend backend.Backend) *HandlerSet

func (*HandlerSet) AddHandler

func (m *HandlerSet) AddHandler(objType kclient.Object, handler Handler)

func (*HandlerSet) Start

func (m *HandlerSet) Start(ctx context.Context) error

func (*HandlerSet) WatchGVK

func (m *HandlerSet) WatchGVK(gvks ...schema.GroupVersionKind) error

type IgnoreNilHandler

type IgnoreNilHandler struct {
	Next Handler
}

func (IgnoreNilHandler) Handle

func (i IgnoreNilHandler) Handle(req Request, resp Response) error

type IgnoreRemoveHandler

type IgnoreRemoveHandler struct {
	Next Handler
}

func (IgnoreRemoveHandler) Handle

func (i IgnoreRemoveHandler) Handle(req Request, resp Response) error

type Middleware

type Middleware func(h Handler) Handler

type NameNamespaceFilter

type NameNamespaceFilter struct {
	Next      Handler
	Name      string
	Namespace string
}

func (NameNamespaceFilter) Handle

func (n NameNamespaceFilter) Handle(req Request, resp Response) error

type Request

type Request struct {
	Client      kclient.WithWatch
	Object      kclient.Object
	Ctx         context.Context
	GVK         schema.GroupVersionKind
	Namespace   string
	Name        string
	Key         string
	FromTrigger bool
}

func (*Request) Delete

func (r *Request) Delete(object kclient.Object) error

func (*Request) Get

func (r *Request) Get(object kclient.Object, namespace, name string) error

func (*Request) List

func (r *Request) List(object kclient.ObjectList, opts *kclient.ListOptions) error

func (*Request) WithContext

func (r *Request) WithContext(ctx context.Context) Request

type Response

type Response interface {
	Attributes() map[string]any
	DisablePrune()
	RetryAfter(delay time.Duration)
	Objects(obj ...kclient.Object)
}

type ResponseAttributes

type ResponseAttributes struct {
	// contains filtered or unexported fields
}

func (*ResponseAttributes) Attributes

func (r *ResponseAttributes) Attributes() map[string]any

type ResponseWrapper

type ResponseWrapper struct {
	NoPrune bool
	Delay   time.Duration
	Objs    []kclient.Object
	Attr    map[string]any
}

func (*ResponseWrapper) Attributes

func (r *ResponseWrapper) Attributes() map[string]any

func (*ResponseWrapper) DisablePrune

func (r *ResponseWrapper) DisablePrune()

func (*ResponseWrapper) Objects

func (r *ResponseWrapper) Objects(obj ...kclient.Object)

func (*ResponseWrapper) RetryAfter

func (r *ResponseWrapper) RetryAfter(delay time.Duration)

type RouteBuilder

type RouteBuilder struct {
	// contains filtered or unexported fields
}

func (RouteBuilder) FieldSelector

func (r RouteBuilder) FieldSelector(sel fields.Selector) RouteBuilder

func (RouteBuilder) Finalize

func (r RouteBuilder) Finalize(finalizerID string, h Handler)

func (RouteBuilder) FinalizeFunc

func (r RouteBuilder) FinalizeFunc(finalizerID string, h HandlerFunc)

func (RouteBuilder) Handler

func (r RouteBuilder) Handler(h Handler)

func (RouteBuilder) HandlerFunc

func (r RouteBuilder) HandlerFunc(h HandlerFunc)

func (RouteBuilder) IncludeFinalizing

func (r RouteBuilder) IncludeFinalizing() RouteBuilder

func (RouteBuilder) IncludeRemoved

func (r RouteBuilder) IncludeRemoved() RouteBuilder

func (RouteBuilder) Middleware

func (r RouteBuilder) Middleware(m ...Middleware) RouteBuilder

func (RouteBuilder) Name

func (r RouteBuilder) Name(name string) RouteBuilder

func (RouteBuilder) Namespace

func (r RouteBuilder) Namespace(namespace string) RouteBuilder

func (RouteBuilder) Selector

func (r RouteBuilder) Selector(sel labels.Selector) RouteBuilder

func (RouteBuilder) Type

func (r RouteBuilder) Type(objType kclient.Object) RouteBuilder

type Router

type Router struct {
	RouteBuilder

	OnErrorHandler ErrorHandler
	// contains filtered or unexported fields
}

func New

func New(handlerSet *HandlerSet, electionConfig *leader.ElectionConfig, healthzPort int) *Router

New returns a new *Router with given HandlerSet and ElectionConfig. Passing a nil ElectionConfig is valid and results in no leader election for the router. The healthzPort is the port on which the healthz endpoint will be served. If <= 0, the healthz endpoint will not be served. When creating multiple routers, the first router created with a positive healthzPort will be used. The healthz endpoint is served on /healthz, and will not be started until the router is started.

func (*Router) Backend

func (r *Router) Backend() backend.Backend

func (*Router) Handle

func (r *Router) Handle(objType kclient.Object, h Handler)

func (*Router) HandleFunc

func (r *Router) HandleFunc(objType kclient.Object, h HandlerFunc)

func (*Router) Start

func (r *Router) Start(ctx context.Context) error

type SelectorFilter

type SelectorFilter struct {
	Next     Handler
	Selector labels.Selector
}

func (SelectorFilter) Handle

func (s SelectorFilter) Handle(req Request, resp Response) error

type TriggerRegistry

type TriggerRegistry interface {
	Watch(obj runtime.Object, namespace, name string, selector labels.Selector, fields fields.Selector) error
	WatchingGVKs() []schema.GroupVersionKind
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL