Documentation
¶
Overview ¶
Package collection implements a collection of resources of a single (namespace, type) pair.
Index ¶
- type Collection
- func (collection *Collection) Create(ctx context.Context, res resource.Resource, owner string) error
- func (collection *Collection) Destroy(ctx context.Context, ptr resource.Pointer, owner string) error
- func (collection *Collection) Get(resourceID resource.ID) (resource.Resource, error)
- func (collection *Collection) List(options *state.ListOptions) (resource.List, error)
- func (collection *Collection) Load(res resource.Resource)
- func (collection *Collection) Update(ctx context.Context, newResource resource.Resource, ...) error
- func (collection *Collection) Watch(ctx context.Context, id resource.ID, ch chan<- state.Event, ...) error
- func (collection *Collection) WatchAll(ctx context.Context, singleCh chan<- state.Event, aggCh chan<- []state.Event, ...) error
- type Store
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) 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.