Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 57

README

store

A library which serves storing data in a generic interface

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyOption

type ApplyOption interface {
	// ApplyToGet applies this configuration to the given get options.
	ApplyToApply(*ApplyOptions)
}

type ApplyOptions

type ApplyOptions struct {
}

func (*ApplyOptions) ApplyOptions

func (o *ApplyOptions) ApplyOptions(opts []ApplyOption) *ApplyOptions

ApplyOptions applies the given get options on these options, and then returns itself (for convenient chaining).

func (*ApplyOptions) ApplyToApply

func (o *ApplyOptions) ApplyToApply(lo *ApplyOptions)

type BranchUnstructuredStore

type BranchUnstructuredStore interface {
	UnstructuredStore
}

type CreateOption

type CreateOption interface {
	// ApplyToGet applies this configuration to the given get options.
	ApplyToCreate(*CreateOptions)
}

type CreateOptions

type CreateOptions struct {
}

func (*CreateOptions) ApplyOptions

func (o *CreateOptions) ApplyOptions(opts []CreateOption) *CreateOptions

func (*CreateOptions) ApplyToCreate

func (o *CreateOptions) ApplyToCreate(lo *CreateOptions)

type DeleteOption

type DeleteOption interface {
	// ApplyToGet applies this configuration to the given get options.
	ApplyToDelete(*DeleteOptions)
}

type DeleteOptions

type DeleteOptions struct {
}

func (*DeleteOptions) ApplyOptions

func (o *DeleteOptions) ApplyOptions(opts []DeleteOption) *DeleteOptions

func (*DeleteOptions) ApplyToDelete

func (o *DeleteOptions) ApplyToDelete(lo *DeleteOptions)

type GetOption

type GetOption interface {
	// ApplyToGet applies this configuration to the given get options.
	ApplyToGet(*GetOptions)
}

type GetOptions

type GetOptions struct {
	Commit *object.Commit
}

func (*GetOptions) ApplyOptions

func (o *GetOptions) ApplyOptions(opts []GetOption) *GetOptions

ApplyOptions applies the given get options on these options, and then returns itself (for convenient chaining).

func (*GetOptions) ApplyToGet

func (o *GetOptions) ApplyToGet(lo *GetOptions)

type Key

type Key struct {
	Branch string
	types.NamespacedName
}

func KeyFromNSN

func KeyFromNSN(nsn types.NamespacedName) Key

KeyFromNSN takes a types.NamespacedName and returns it wrapped in the Key struct.

func ToKey

func ToKey(name string) Key

ToKey takes a resource name and returns a types.NamespacedName initialized with the name. The namespace attribute however is uninitialized.

func (Key) String

func (r Key) String() string

String returns the key as a string <namespace>.<name> or <name> depending on the presence of the namespace

type ListOption

type ListOption interface {
	// ApplyToList applies this configuration to the given get options.
	ApplyToList(*ListOptions)
}

type ListOptions

type ListOptions struct {
	Commit *object.Commit
	Watch  bool
}

func (*ListOptions) ApplyOptions

func (o *ListOptions) ApplyOptions(opts []ListOption) *ListOptions

ApplyOptions applies the given get options on these options, and then returns itself (for convenient chaining).

func (*ListOptions) ApplyToList

func (o *ListOptions) ApplyToList(lo *ListOptions)

type Storer

type Storer[T1 any] interface {
	// Starting the watcher manager
	Start(context.Context)

	// Stopping the watcher manager
	Stop()
	// Retrieve retrieves data for the given key from the storage
	Get(key Key, opts ...GetOption) (T1, error)

	// Retrieve retrieves data for the given key from the storage
	List(visitorFunc func(Key, T1), opts ...ListOption)

	// Retrieve retrieves data for the given key from the storage
	ListKeys(opts ...ListOption) []string

	// Len returns the # entries in the store
	Len(opts ...ListOption) int

	Apply(key Key, data T1, opts ...ApplyOption) error

	// Create data with the given key in the storage
	Create(key Key, data T1, opts ...CreateOption) error

	// Update data with the given key in the storage
	Update(key Key, data T1, opts ...UpdateOption) error

	// Update data in a concurrent way through a function
	UpdateWithKeyFn(key Key, updateFunc func(obj T1) T1)

	// Delete deletes data and key from the storage
	Delete(key Key, opts ...DeleteOption) error

	// Watch watches change
	Watch(ctx context.Context, opts ...ListOption) (watch.WatchInterface[T1], error)
}

Storer defines the interface for a generic storage system.

type UnstructuredStore

type UnstructuredStore interface {
	// Retrieve retrieves data for the given key from the storage
	Get(key Key, opts ...GetOption) (runtime.Unstructured, error)

	// Retrieve retrieves data for the given key from the storage
	List(visitorFunc func(key Key, obj runtime.Unstructured), opts ...ListOption)

	// Retrieve retrieves data for the given key from the storage
	ListKeys(opts ...ListOption) []string

	// Len returns the # entries in the store
	Len(opts ...ListOption) int

	Apply(key Key, obj runtime.Unstructured, opts ...ApplyOption) error

	// Create data with the given key in the storage
	Create(key Key, obj runtime.Unstructured, opts ...CreateOption) error

	// Update data with the given key in the storage
	Update(key Key, obj runtime.Unstructured, opts ...UpdateOption) error

	// Update data in a concurrent way through a function
	UpdateWithKeyFn(key Key, updateFunc func(obj runtime.Unstructured, opts ...UpdateOption) runtime.Unstructured)

	// Delete deletes data and key from the storage
	Delete(key Key, opts ...DeleteOption) error

	// Watch watches change
	Watch(ctx context.Context, opts ...ListOption) (watch.WatchInterface[runtime.Unstructured], error)
}

type UpdateOption

type UpdateOption interface {
	// ApplyToGet applies this configuration to the given get options.
	ApplyToUpdate(*UpdateOptions)
}

type UpdateOptions

type UpdateOptions struct {
}

func (*UpdateOptions) ApplyOptions

func (o *UpdateOptions) ApplyOptions(opts []UpdateOption) *UpdateOptions

func (*UpdateOptions) ApplyToUpdate

func (o *UpdateOptions) ApplyToUpdate(lo *UpdateOptions)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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