customdata

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

Data represents a custom data

type Kind

type Kind struct {
	// Name is the name of the Kind
	Name string `yaml:"name" jsonschema:"required"`
	// IDField is a field name of custom data of this kind, this field is the ID
	// of the data, that's unique among the same kind, the default value is 'name'.
	IDField string `yaml:"idField" jsonschema:"omitempty"`
	// JSONSchema is JSON schema to validate a custom data of this kind
	JSONSchema dynamicobject.DynamicObject `yaml:"jsonSchema" jsonschema:"omitempty"`
}

Kind defines the spec of a custom data kind

type Store

type Store struct {
	KindPrefix string
	DataPrefix string
	// contains filtered or unexported fields
}

Store defines the storage for custom data

func NewStore

func NewStore(cls cluster.Cluster, kindPrefix string, dataPrefix string) *Store

NewStore creates a new custom data store

func (*Store) BatchUpdateData

func (s *Store) BatchUpdateData(kind string, del []string, update []Data) error

BatchUpdateData updates multiple custom data in a transaction

func (*Store) DeleteAllData

func (s *Store) DeleteAllData(kind string) error

DeleteAllData deletes all custom data of kind 'kind'

func (*Store) DeleteData

func (s *Store) DeleteData(kind string, id string) error

DeleteData deletes a custom data

func (*Store) DeleteKind

func (s *Store) DeleteKind(name string) error

DeleteKind deletes a custom data kind

func (*Store) GetData

func (s *Store) GetData(kind string, id string) (Data, error)

GetData gets custom data by its id

func (*Store) GetKind

func (s *Store) GetKind(name string) (*Kind, error)

GetKind gets custom data kind by its name

func (*Store) ListData

func (s *Store) ListData(kind string) ([]Data, error)

ListData lists custom data of specified kind. if kind is empty, it returns custom data of all kinds.

func (*Store) ListKinds

func (s *Store) ListKinds() ([]*Kind, error)

ListKinds lists custom data kinds

func (*Store) PutData

func (s *Store) PutData(kind string, data Data, update bool) (string, error)

PutData creates or updates a custom data item

func (*Store) PutKind

func (s *Store) PutKind(kind *Kind, update bool) error

PutKind creates or updates a custom data kind

func (*Store) Watch

func (s *Store) Watch(ctx context.Context, kind string, onChange func([]Data)) error

Watch watches the data of custom data kind 'kind'

Jump to

Keyboard shortcuts

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