workpool

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultScaleInWorkerQueueDuration define the duration to scale in the workers.
	DefaultScaleInWorkerQueueDuration = time.Hour * 3
	ScaleInQueueThreshold             = 0.75
	ControllerFinalizer               = "cloudshell.cloudtty.io/worker-pool"
	ErrNotWorker                      = errors.New("There is no worker in pool")
)

Functions

func SplitWorkerKey

func SplitWorkerKey(key string) (namespace, name, image string, err error)

SplitWorkerKey returns the namespace, name, image that WorkerKeyFunc encoded into key.

packing/unpacking won't be necessary.

func WorkerKeyFunc

func WorkerKeyFunc(obj interface{}) (string, error)

Types

type Interface

type Interface interface {
	Add(item interface{})
	Len() int
	Get() interface{}
	Remove(item interface{})
	Has(item interface{}) bool
	All() []interface{}
}

type Request

type Request struct {
	Cloudshell      string
	Namespace       string
	Image           string
	CloudShellQueue workqueue.RateLimitingInterface
}

Request represents a request to borrow a worker from worker pool. if the delay is true, the cloudshell queue must not be empty, because when the worker is running, it needs to inform the controller.

type Type

type Type struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Type) Add

func (q *Type) Add(item interface{})

func (*Type) All

func (q *Type) All() []interface{}

func (*Type) Get

func (q *Type) Get() interface{}

func (*Type) Has

func (q *Type) Has(item interface{}) bool

func (*Type) Len

func (q *Type) Len() int

func (*Type) Remove

func (q *Type) Remove(item interface{})

type WorkerPool

type WorkerPool struct {
	sync.Mutex
	client.Client
	// contains filtered or unexported fields
}

func New

func New(client client.Client, coreWorkerLimit, maxWorkerLimit int, podInformer informercorev1.PodInformer) *WorkerPool

func (*WorkerPool) Back

func (w *WorkerPool) Back(worker *corev1.Pod) error

func (*WorkerPool) Borrow

func (w *WorkerPool) Borrow(req *Request) (*corev1.Pod, error)

func (*WorkerPool) CreateServiceFor added in v0.6.0

func (w *WorkerPool) CreateServiceFor(_ context.Context, worker *corev1.Pod) error

func (*WorkerPool) Run

func (w *WorkerPool) Run(stopCh <-chan struct{})

Jump to

Keyboard shortcuts

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