persistentcollection

package
v0.0.0-kmdagger1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: AGPL-3.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 CollectionFileContents

type CollectionFileContents[T any] struct {
	Version int `json:"version"`
	Items   []T `json:"items"`
}

type PersistentCollection

type PersistentCollection[T any] interface {
	Delete(ctx context.Context, namespace string, predicate Predicate[T]) (deletedCount int, err error)
	FindFirst(ctx context.Context, namespace string, predicate Predicate[T]) (T, error)
	Find(ctx context.Context, namespace string, predicate Predicate[T]) ([]T, error)
	Update(ctx context.Context, namespace string, updateFn UpdateFn[T]) (updatedCount int, err error)
	Insert(ctx context.Context, namespace string, item T) error
}

PersistentCollection is a collection of items that's going to retain its state between Grafana restarts. The main purpose of this API is to reduce the time-to-Proof-of-Concept - this is NOT intended for production use.

The item type needs to be serializable to JSON. @alpha -- EXPERIMENTAL

func NewLocalFSPersistentCollection

func NewLocalFSPersistentCollection[T any](name string, directory string, version int) PersistentCollection[T]

type Predicate

type Predicate[T any] func(item T) (bool, error)

type UpdateFn

type UpdateFn[T any] func(item T) (updated bool, updatedItem T, err error)

Jump to

Keyboard shortcuts

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