sync

package
v0.0.0-...-10a646c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketFunc

type BucketFunc func(Key) BucketKey
var NamespaceBucket BucketFunc = func(key Key) BucketKey {
	namespace, _, _ := cache.SplitMetaNamespaceKey(key)
	return namespace
}
var SingleBucket BucketFunc = func(key Key) BucketKey { return "" }

type BucketKey

type BucketKey = string

type GetSyncLimit

type GetSyncLimit func(string) (int, error)

type IsSDDeleted

type IsSDDeleted func(string) bool

type Key

type Key = string

type LockName

type LockName struct {
	Namespace string
	RepoName  string
}

func DecodeLockName

func DecodeLockName(lockName string) (*LockName, error)

func GetLockName

func GetLockName(sd *v1alpha1.SimpleDeployment) (*LockName, error)

func NewLockName

func NewLockName(namespace, repoName string) *LockName

func (*LockName) EncodeName

func (ln *LockName) EncodeName() string

type Manager

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

func NewLockManager

func NewLockManager(getSyncLimit GetSyncLimit, nextSD NextSD, isSDDeleted IsSDDeleted) *Manager

func (*Manager) Release

func (cm *Manager) Release(sd *v1alpha1.SimpleDeployment)

func (*Manager) TryAcquire

func (cm *Manager) TryAcquire(sd *v1alpha1.SimpleDeployment) (bool, bool, string, error)

type NextSD

type NextSD func(obj interface{})

type PrioritySemaphore

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

func NewSemaphore

func NewSemaphore(name string, limit int, nextSD NextSD) *PrioritySemaphore

type QueueFunc

type QueueFunc func(Key)

type Semaphore

type Semaphore interface {
	// contains filtered or unexported methods
}

type Throttler

type Throttler interface {
	Init(wfs []v1alpha1.SimpleDeployment) error
	Add(key Key, priority int32, creationTime time.Time)
	// Admit returns if the item should be processed.
	Admit(key Key) bool
	// Remove notifies throttler that item processing is no longer needed
	Remove(key Key)
}

Throttler allows the controller to limit number of items it is processing in parallel. Items are processed in priority order, and one processing starts, other items (including higher-priority items) will be kept pending until the processing is complete. Implementations should be idempotent.

func NewThrottler

func NewThrottler(parallelism int, bucketFunc BucketFunc, queue QueueFunc) Throttler

NewThrottler returns a throttle that only runs `parallelism` items at once. When an item may need processing, `queue` is invoked.

Jump to

Keyboard shortcuts

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