yacht

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 14 Imported by: 14

README

Yacht

GoPkg Widget License GoVersion Go Report Card build Version codecov


Light-weighted Kubernetes controller-runtime Framework with Minimal Dependencies


Why Building Yacht

Well, there are quite a few controller/operator frameworks out there, such as kubebuilder, operator-sdk, controller-runtime. But they are not quite handy.

First of all, building a scaffold project may not be what we really need. Most of the time, we are not trying to build a project from scratch, but rather adding new controllers on an existing project. Moreover, the structure of the scaffold project does not suit all. It is not easy to customize the scaffolds according to our own preferences.

Secondly, backwards compatibility. Most frameworks DO NOT guarantee any particular compatibility matrix between kubernetes library dependencies (client-go, apimachinery, etc). This is painful when we want to pin Kubernetes library dependencies to any specific lower versions. It has always been a headache to upgrade/downgrade the versions of frameworks and Kubernetes library dependencies.

Last but not least, we DO want a light-weighted framework with minimal dependencies.

That's why I build yacht, which brings pleasure user experiences on writing Kubernetes controllers. It is built with minimal dependencies, which makes it easier to downgrade/upgrade module versions.

To Start Using Yacht

  1. Add github.com/dixudx/yacht to your go.mod file.
  2. Follow yacht examples and learn how to use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultEnqueueFunc

func DefaultEnqueueFunc(obj interface{}) (interface{}, error)

DefaultEnqueueFunc uses a default namespacedKey as its KeyFunc. The key uses the format <namespace>/<name> unless <namespace> is empty, then it's just <name>.

Types

type Controller

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

func NewController

func NewController(name string) *Controller

NewController creates a new Controller

func (*Controller) DefaultResourceEventHandlerFuncs added in v0.2.0

func (c *Controller) DefaultResourceEventHandlerFuncs() cache.ResourceEventHandlerFuncs

func (*Controller) Enqueue

func (c *Controller) Enqueue(obj interface{})

Enqueue takes an object and converts it into a key (could be a string, or a struct) which is then put onto the work queue.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context)

Run will start multiple workers to process work items from work queue. It will block until ctx is closed.

func (*Controller) WithCacheSynced

func (c *Controller) WithCacheSynced(informersSynced ...cache.InformerSynced) *Controller

WithCacheSynced sets all the resource cacheSynced

func (*Controller) WithEnqueueFilterFunc added in v0.2.0

func (c *Controller) WithEnqueueFilterFunc(enqueueFilterFunc EnqueueFilterFunc) *Controller

WithEnqueueFilterFunc sets customize enqueueFilterFunc

func (*Controller) WithEnqueueFunc

func (c *Controller) WithEnqueueFunc(enqueueFunc EnqueueFunc) *Controller

WithEnqueueFunc sets customize enqueueFunc

func (*Controller) WithHandlerContextFunc added in v0.8.0

func (c *Controller) WithHandlerContextFunc(handlerContextFunc HandlerContextFunc) *Controller

WithHandlerContextFunc sets a handler function to process the work item off the work queue

func (*Controller) WithHandlerFunc

func (c *Controller) WithHandlerFunc(handlerFunc HandlerFunc) *Controller

WithHandlerFunc sets a handler function to process the work item off the work queue Deprecated: Use WithHandlerContextFunc instead.

func (*Controller) WithLeaderElection

func (c *Controller) WithLeaderElection(leaseLock rl.Interface, leaseDuration, renewDeadline, retryPeriod time.Duration) *Controller

WithLeaderElection uses leader election to get the lock

func (*Controller) WithQueue added in v0.7.0

WithQueue replaces the default queue with the desired one to store work items.

func (*Controller) WithWorkers

func (c *Controller) WithWorkers(workers int) *Controller

WithWorkers sets the number of workers to process work items off work queue

type EnqueueFilterFunc added in v0.2.0

type EnqueueFilterFunc func(oldObj, newObj interface{}) (bool, error)

type EnqueueFunc

type EnqueueFunc func(obj interface{}) (interface{}, error)

type HandlerContextFunc added in v0.8.0

type HandlerContextFunc func(ctx context.Context, key interface{}) (requeueAfter *time.Duration, err error)

type HandlerFunc deprecated

type HandlerFunc func(key interface{}) (requeueAfter *time.Duration, err error)

Deprecated: Use HandlerContextFunc instead.

type Interface

type Interface interface {
	Enqueue(obj interface{})
	WithEnqueueFunc(EnqueueFunc) *Controller
	// Deprecated: Use WithHandlerContextFunc instead.
	WithHandlerFunc(HandlerFunc) *Controller
	WithHandlerContextFunc(HandlerContextFunc) *Controller
	WithLeaderElection(leaseLock rl.Interface, leaseDuration, renewDeadline, retryPeriod time.Duration) *Controller
	WithCacheSynced(...cache.InformerSynced) *Controller
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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