Documentation ¶
Overview ¶
Package schema implements CRUD schema.
Index ¶
- Variables
- func BadRequest(field, desc string) error
- type EqualityChecker
- type EventHandler
- type Group
- type HasMetadata
- type IndexRule
- type IndexRuleBinding
- type Kind
- type ListOpt
- type Measure
- type Metadata
- type Node
- type Property
- type Registry
- type RegistryOption
- func ConfigureEtcdTLSCAFile(file string) RegistryOption
- func ConfigureEtcdTLSCertAndKey(certFile string, keyFile string) RegistryOption
- func ConfigureEtcdUser(username string, password string) RegistryOption
- func ConfigureServerEndpoints(url []string) RegistryOption
- func Namespace(namespace string) RegistryOption
- type Spec
- type Stream
- type TopNAggregation
- type TypeMeta
- type UnimplementedOnInitHandler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrGRPCResourceNotFound indicates the resource doesn't exist. ErrGRPCResourceNotFound = statusGRPCResourceNotFound.Err() // ErrClosed indicates the registry is closed. ErrClosed = errors.New("metadata registry is closed") // ErrGRPCAlreadyExists indicates the resource already exists. ErrGRPCAlreadyExists = statusGRPCAlreadyExists.Err() )
var CheckerMap = map[Kind]EqualityChecker{ KindIndexRuleBinding: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&databasev1.IndexRuleBinding{}, "updated_at"), protocmp.IgnoreFields(&commonv1.Metadata{}, "id", "create_revision", "mod_revision"), protocmp.Transform(), ) }, KindIndexRule: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&databasev1.IndexRule{}, "updated_at"), protocmp.IgnoreFields(&commonv1.Metadata{}, "id", "create_revision", "mod_revision"), protocmp.Transform(), ) }, KindMeasure: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&databasev1.Measure{}, "updated_at"), protocmp.IgnoreFields(&commonv1.Metadata{}, "id", "create_revision", "mod_revision"), protocmp.Transform(), ) }, KindStream: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&databasev1.Stream{}, "updated_at"), protocmp.IgnoreFields(&commonv1.Metadata{}, "id", "create_revision", "mod_revision"), protocmp.Transform()) }, KindGroup: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&databasev1.Stream{}, "updated_at"), protocmp.IgnoreFields(&commonv1.Metadata{}, "id", "create_revision", "mod_revision"), protocmp.Transform()) }, KindTopNAggregation: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&databasev1.TopNAggregation{}, "updated_at"), protocmp.IgnoreFields(&commonv1.Metadata{}, "id", "create_revision", "mod_revision"), protocmp.Transform()) }, KindProperty: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&propertyv1.Property{}, "updated_at"), protocmp.IgnoreFields(&commonv1.Metadata{}, "id", "create_revision", "mod_revision"), protocmp.Transform()) }, KindNode: func(a, b proto.Message) bool { return cmp.Equal(a, b, protocmp.IgnoreUnknown(), protocmp.IgnoreFields(&databasev1.Node{}, "created_at"), protocmp.Transform()) }, KindMask: func(_, _ proto.Message) bool { return false }, }
CheckerMap to map each Kind to its EqualityChecker.
Functions ¶
func BadRequest ¶
BadRequest creates a gRPC error with error details with type BadRequest, which describes violations in a client request.
Types ¶
type EqualityChecker ¶ added in v0.6.1
EqualityChecker Type Function.
type EventHandler ¶
type EventHandler interface { OnInit([]Kind) (bool, []int64) 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 ¶
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.
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 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 GetNode(ctx context.Context, node string) (*databasev1.Node, 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 ¶
type Registry interface { io.Closer Stream IndexRule IndexRuleBinding Measure Group TopNAggregation Property Node RegisterHandler(string, Kind, EventHandler) NewWatcher(string, Kind, watchEventHandler) *watcher Register(context.Context, Metadata, bool) error }
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 ConfigureEtcdTLSCAFile ¶ added in v0.6.0
func ConfigureEtcdTLSCAFile(file string) RegistryOption
ConfigureEtcdTLSCAFile sets a trusted ca file of the etcd tls config.
func ConfigureEtcdTLSCertAndKey ¶ added in v0.6.0
func ConfigureEtcdTLSCertAndKey(certFile string, keyFile string) RegistryOption
ConfigureEtcdTLSCertAndKey sets a cert & key of the etcd tls config.
func ConfigureEtcdUser ¶ added in v0.6.0
func ConfigureEtcdUser(username string, password string) RegistryOption
ConfigureEtcdUser sets a username & password of the etcd.
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 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 UnimplementedOnInitHandler ¶ added in v0.6.0
type UnimplementedOnInitHandler struct{}
UnimplementedOnInitHandler is a placeholder for unimplemented OnInitHandler.