store

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	Namespace string
	Name      string
}

Key is used to identify objects in store

func KeyOf

func KeyOf(obj metav1.Object) Key

KeyOf creates a key from an object

type ObjectStore

type ObjectStore interface {
	Put(metav1.Object)
	OverrideResourceVersionIfNewer(metav1.Object) bool
	PutIfAbsent(metav1.Object) bool
	Get(Key) (metav1.Object, bool)
	Delete(Key)
	List() []metav1.Object
}

ObjectStore is a thread safe store for kubernetes resources

func NewStore

func NewStore(ctx context.Context) ObjectStore

NewStore creates an empty store

type Request

type Request struct {
	Key        Key
	Type       RequestType
	RetryCount int
}

Request is a write request for an object

func CreateRequest

func CreateRequest(obj metav1.Object) Request

CreateRequest creates a create request for an object

func DeleteRequest

func DeleteRequest(objKey Key) Request

DeleteRequest creates a delete request for an object

func UpdateRequest

func UpdateRequest(obj metav1.Object) Request

UpdateRequest creates an update request for an object

func (Request) WithIncrementedRetryCount

func (rq Request) WithIncrementedRetryCount() Request

WithIncrementedRetryCount returns the same request with an incremented RetryCount

type RequestType

type RequestType int

RequestType denotes the type of write request

const (
	// CreateRequestType denotes create requests
	CreateRequestType RequestType = 0
	// UpdateRequestType denotes update requests
	UpdateRequestType RequestType = 1
	// DeleteRequestType denotes delete requests
	DeleteRequestType RequestType = 2
)

type ShardedUniqueQueue

type ShardedUniqueQueue interface {
	TryAddIfAbsent(Request) bool
	AddIfAbsent(Request)
	GetConsumers() []<-chan func() Request
	QueueLengths() []int
}

ShardedUniqueQueue is a queue of write requests for objects. It compacts consecutive create and update requests, provides a slice of channels for consumers. No two requests for the same object will end up in different consumers.

func NewShardedUniqueQueue

func NewShardedUniqueQueue(buckets int) ShardedUniqueQueue

NewShardedUniqueQueue creates a sharded queue of write requests

Jump to

Keyboard shortcuts

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