collection

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MPL-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package collection implements a collection of resources of a single (namespace, type) pair.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

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

Collection is a set of resources of a single (namespace, type) pair.

Collection publishes the changes to a feed of the event buffer shared with the other collections.

func New

func New(ns resource.Namespace, typ resource.Type, buffer *eventbuffer.Buffer, store Store) *Collection

New returns a new Collection which publishes its events to a feed of the buffer.

The store is optional, if it is nil the collection is kept in memory only.

func (*Collection) Create

func (collection *Collection) Create(ctx context.Context, res resource.Resource, owner string) error

Create a resource.

func (*Collection) Destroy

func (collection *Collection) Destroy(ctx context.Context, ptr resource.Pointer, owner string) error

Destroy a resource.

func (*Collection) Get

func (collection *Collection) Get(resourceID resource.ID) (resource.Resource, error)

Get a resource.

func (*Collection) List

func (collection *Collection) List(options *state.ListOptions) (resource.List, error)

List resources.

func (*Collection) Load

func (collection *Collection) Load(res resource.Resource)

Load injects a resource loaded from the backing store.

func (*Collection) Update

func (collection *Collection) Update(ctx context.Context, newResource resource.Resource, options *state.UpdateOptions) error

Update a resource.

func (*Collection) Watch

func (collection *Collection) Watch(ctx context.Context, id resource.ID, ch chan<- state.Event, opts ...state.WatchOption) error

Watch for the changes of a single resource.

func (*Collection) WatchAll

func (collection *Collection) WatchAll(ctx context.Context, singleCh chan<- state.Event, aggCh chan<- []state.Event, opts ...state.WatchKindOption) error

WatchAll for any resource change in this collection.

Events are sent either to singleCh or to aggCh (aggregated), whichever is not nil.

type Store

type Store interface {
	// Put the resource to the store.
	Put(ctx context.Context, ns resource.Namespace, resourceType resource.Type, resource resource.Resource) error
	// Destroy the resource from the store.
	Destroy(ctx context.Context, ns resource.Namespace, resourceType resource.Type, resourcePointer resource.Pointer) error
}

Store persists the contents of a collection.

Store is a subset of inmem.BackingStore which is scoped to the operations a collection performs.

Jump to

Keyboard shortcuts

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