schema

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package schema implements CRUD schema.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGRPCResourceNotFound indicates the resource doesn't exist.
	ErrGRPCResourceNotFound = statusGRPCResourceNotFound.Err()
	// ErrClosed indicates the registry is closed.
	ErrClosed = errors.New("metadata registry is closed")
)

Functions

func BadRequest

func BadRequest(field, desc string) error

BadRequest creates a gRPC error with error details with type BadRequest, which describes violations in a client request.

Types

type EventHandler

type EventHandler interface {
	OnAddOrUpdate(Metadata)
	OnDelete(Metadata)
}

EventHandler allows receiving and handling the resource change events.

type Group

type Group interface {
	GetGroup(ctx context.Context, group string) (*commonv1.Group, error)
	ListGroup(ctx context.Context) ([]*commonv1.Group, error)
	// DeleteGroup delete all items belonging to the group
	DeleteGroup(ctx context.Context, group string) (bool, error)
	CreateGroup(ctx context.Context, group *commonv1.Group) error
	UpdateGroup(ctx context.Context, group *commonv1.Group) error
}

Group allows CRUD groups which is namespaces of resources.

type HasMetadata

type HasMetadata interface {
	GetMetadata() *commonv1.Metadata
	proto.Message
}

HasMetadata allows getting Metadata.

type IndexRule

type IndexRule interface {
	GetIndexRule(ctx context.Context, metadata *commonv1.Metadata) (*databasev1.IndexRule, error)
	ListIndexRule(ctx context.Context, opt ListOpt) ([]*databasev1.IndexRule, error)
	CreateIndexRule(ctx context.Context, indexRule *databasev1.IndexRule) error
	UpdateIndexRule(ctx context.Context, indexRule *databasev1.IndexRule) error
	DeleteIndexRule(ctx context.Context, metadata *commonv1.Metadata) (bool, error)
}

IndexRule allows CRUD index rule schemas in a group.

type IndexRuleBinding

type IndexRuleBinding interface {
	GetIndexRuleBinding(ctx context.Context, metadata *commonv1.Metadata) (*databasev1.IndexRuleBinding, error)
	ListIndexRuleBinding(ctx context.Context, opt ListOpt) ([]*databasev1.IndexRuleBinding, error)
	CreateIndexRuleBinding(ctx context.Context, indexRuleBinding *databasev1.IndexRuleBinding) error
	UpdateIndexRuleBinding(ctx context.Context, indexRuleBinding *databasev1.IndexRuleBinding) error
	DeleteIndexRuleBinding(ctx context.Context, metadata *commonv1.Metadata) (bool, error)
}

IndexRuleBinding allows CRUD index rule binding schemas in a group.

type Kind

type Kind int

Kind is the type of a resource.

const (
	KindGroup Kind = 1 << iota
	KindStream
	KindMeasure
	KindIndexRuleBinding
	KindIndexRule
	KindTopNAggregation
	KindProperty
	KindNode
	KindMask = KindGroup | KindStream | KindMeasure |
		KindIndexRuleBinding | KindIndexRule |
		KindTopNAggregation | KindProperty | KindNode
	KindSize = 9
)

KindMask tends to check whether an event is valid.

func (Kind) String added in v0.5.0

func (k Kind) String() string

func (Kind) Unmarshal added in v0.5.0

func (k Kind) Unmarshal(kv *mvccpb.KeyValue) (Metadata, error)

Unmarshal encode bytes to proto.Message.

type ListOpt

type ListOpt struct {
	Group string
}

ListOpt contains options to list resources.

type Measure

type Measure interface {
	GetMeasure(ctx context.Context, metadata *commonv1.Metadata) (*databasev1.Measure, error)
	ListMeasure(ctx context.Context, opt ListOpt) ([]*databasev1.Measure, error)
	CreateMeasure(ctx context.Context, measure *databasev1.Measure) (int64, error)
	UpdateMeasure(ctx context.Context, measure *databasev1.Measure) (int64, error)
	DeleteMeasure(ctx context.Context, metadata *commonv1.Metadata) (bool, error)
	TopNAggregations(ctx context.Context, metadata *commonv1.Metadata) ([]*databasev1.TopNAggregation, error)
}

Measure allows CRUD measure schemas in a group.

type Metadata

type Metadata struct {
	Spec Spec
	TypeMeta
}

Metadata wrap dedicated serialized resource and its TypeMeta.

type Node added in v0.5.0

type Node interface {
	ListNode(ctx context.Context, role databasev1.Role) ([]*databasev1.Node, error)
	RegisterNode(ctx context.Context, node *databasev1.Node, forced bool) error
}

Node allows CRUD node schemas in a group.

type Property

type Property interface {
	GetProperty(ctx context.Context, metadata *propertyv1.Metadata, tags []string) (*propertyv1.Property, error)
	ListProperty(ctx context.Context, container *commonv1.Metadata, ids []string, tags []string) ([]*propertyv1.Property, error)
	ApplyProperty(ctx context.Context, property *propertyv1.Property, strategy propertyv1.ApplyRequest_Strategy) (bool, uint32, int64, error)
	DeleteProperty(ctx context.Context, metadata *propertyv1.Metadata, tags []string) (bool, uint32, error)
	KeepAlive(ctx context.Context, leaseID int64) error
}

Property allows CRUD properties or tags in group.

type Registry

Registry allowing depositing resources.

func NewEtcdSchemaRegistry

func NewEtcdSchemaRegistry(options ...RegistryOption) (Registry, error)

NewEtcdSchemaRegistry returns a Registry powered by Etcd.

type RegistryOption

type RegistryOption func(*etcdSchemaRegistryConfig)

RegistryOption is the option to create Registry.

func ConfigureServerEndpoints added in v0.5.0

func ConfigureServerEndpoints(url []string) RegistryOption

ConfigureServerEndpoints sets a list of the server urls.

func Namespace added in v0.5.0

func Namespace(namespace string) RegistryOption

Namespace sets the namespace of the registry.

type Spec

type Spec interface{}

Spec is a placeholder of a serialized resource.

type Stream

type Stream interface {
	GetStream(ctx context.Context, metadata *commonv1.Metadata) (*databasev1.Stream, error)
	ListStream(ctx context.Context, opt ListOpt) ([]*databasev1.Stream, error)
	CreateStream(ctx context.Context, stream *databasev1.Stream) (int64, error)
	UpdateStream(ctx context.Context, stream *databasev1.Stream) (int64, error)
	DeleteStream(ctx context.Context, metadata *commonv1.Metadata) (bool, error)
}

Stream allows CRUD stream schemas in a group.

type TopNAggregation

type TopNAggregation interface {
	GetTopNAggregation(ctx context.Context, metadata *commonv1.Metadata) (*databasev1.TopNAggregation, error)
	ListTopNAggregation(ctx context.Context, opt ListOpt) ([]*databasev1.TopNAggregation, error)
	CreateTopNAggregation(ctx context.Context, measure *databasev1.TopNAggregation) error
	UpdateTopNAggregation(ctx context.Context, measure *databasev1.TopNAggregation) error
	DeleteTopNAggregation(ctx context.Context, metadata *commonv1.Metadata) (bool, error)
}

TopNAggregation allows CRUD top-n aggregation schemas in a group.

type TypeMeta

type TypeMeta struct {
	Name        string
	Group       string
	ModRevision int64
	Kind        Kind
}

TypeMeta defines the identity and type of an Event.

Jump to

Keyboard shortcuts

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