customdata

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package customdata provides a way to store custom data in Easegress cluster.

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 `json:"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 `json:"idField,omitempty"`
	// JSONSchema is JSON schema to validate a custom data of this kind
	JSONSchema dynamicobject.DynamicObject `json:"jsonSchema,omitempty"`
}

Kind defines the spec of a custom data kind

func (*Kind) DataID

func (k *Kind) DataID(data *Data) string

DataID returns the ID of the custom data

func (*Kind) GetIDField

func (k *Kind) GetIDField() string

GetIDField returns the ID field name of the custom data kind

type KindWithLen

type KindWithLen struct {
	Kind
	Len int `json:"len"`
}

KindWithLen defines the spec of a custom data kind with length

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) DataLen

func (s *Store) DataLen(kind string) (int, error)

DataLen returns the number of custom data of specified kind.

func (*Store) DeleteAllData

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

DeleteAllData deletes all custom data of kind 'kind'

func (*Store) DeleteAllKinds

func (s *Store) DeleteAllKinds() error

DeleteAllKind deletes all custom data kinds with all data

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