async

package
v0.0.0-...-6243be3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncChangeEvent

type AsyncChangeEvent struct {
	DataSourceID uuid.UUID
	EventType    AsyncEventType
	Object       db.Model
	Keys         []uuid.UUID
}

AsyncChangeEvent defines the data received by a data source to signal that an async handleWatchEvent has been received for a given object type.

type AsyncEventHandler

type AsyncEventHandler interface {
	// HandleSyncComplete is used to indicate that the full list of objects has been received.  Any stale objects should now
	// be deleted.
	HandleSyncComplete(ctx context.Context, objectType runtime.Object, keys []uuid.UUID) error
	// HandleAsyncEvent is used to pass objects received from the Reflector to the Collector
	HandleAsyncEvent(ctx context.Context, obj interface{}, eventType AsyncEventType) (uuid.UUID, error)
}

AsyncEventHandler is intended to be implemented by the Collector so that it can receive data from the Reflector via the Store interface.

type AsyncEventType

type AsyncEventType int

AsyncEventType defines the types of async events that are supported between the Collector and Reflector.

const (
	// Updated indicates that the object is inserted or updated
	Updated AsyncEventType = iota
	// Deleted indicates that the object is deleted
	Deleted
	// SyncComplete indicates that the Reflector has re-listed all objects from the API server
	SyncComplete
)

type ReflectorStore

type ReflectorStore struct {
	// ObjectType is an instance of the object type monitored by the Reflector.
	ObjectType runtime.Object
	// contains filtered or unexported fields
}

ReflectorStore defines an adaptation layer between a Reflector and our Collector. This is an alternative to using an Informer which eliminates the need for caching objects in memory. On a system engineered to capacity, this can save us hundreds of MB of memory.

func NewReflectorStore

func NewReflectorStore(objectType runtime.Object) *ReflectorStore

NewReflectorStore creates a new ReflectorStore

func (*ReflectorStore) Add

func (c *ReflectorStore) Add(obj interface{}) error

Add handles a new object being added.

func (*ReflectorStore) Delete

func (c *ReflectorStore) Delete(obj interface{}) error

Delete handles a deleted object

func (*ReflectorStore) Get

func (c *ReflectorStore) Get(_ interface{}) (item interface{}, exists bool, err error)

Get is not supported. We only need this interface to accept incoming data via Add, Update, Delete, and Replace.

func (*ReflectorStore) GetByKey

func (c *ReflectorStore) GetByKey(_ string) (item interface{}, exists bool, err error)

GetByKey is not supported. We only need this interface to accept incoming data via Add, Update, Delete, and Replace.

func (*ReflectorStore) HasSynced

func (c *ReflectorStore) HasSynced() bool

HasSynced is used to determine whether the initial sync operation has completed, which means the initial set of objects has been retrieved from the API server.

func (*ReflectorStore) List

func (c *ReflectorStore) List() []interface{}

List is not supported. We only need this interface to accept incoming data via Add, Update, Delete, and Replace.

func (*ReflectorStore) ListKeys

func (c *ReflectorStore) ListKeys() []string

ListKeys is not supported. We only need this interface to accept incoming data via Add, Update, Delete, and Replace.

func (*ReflectorStore) Receive

func (c *ReflectorStore) Receive(ctx context.Context, handler AsyncEventHandler)

Receive waits for new operations to be enqueued to the work queue and then invokes the handler to process each pending operation. This method does not return unless the context is canceled.

func (*ReflectorStore) Replace

func (c *ReflectorStore) Replace(items []interface{}, resourceVersion string) error

Replace indicates that the underlying Reflector needed to re-list all data from the API server.

func (*ReflectorStore) Resync

func (c *ReflectorStore) Resync() error

Resync indicates that a resync operation has occurred. We do not use this interface.

func (*ReflectorStore) Update

func (c *ReflectorStore) Update(obj interface{}) error

Update handles an update to an object.

Jump to

Keyboard shortcuts

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