schema

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package schema implements a framework to sync schema info from the metadata repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMaxModRevision added in v0.4.0

func ParseMaxModRevision[T ResourceSchema](indexRules []T) (maxRevisionForIdxRules int64)

ParseMaxModRevision gives the max revision from resources' metadata.

Types

type EventKind

type EventKind uint8

EventKind defines category of events.

const (
	EventKindGroup EventKind = iota
	EventKindResource
)

This framework groups events to a hierarchy. A group is the root node.

type EventType

type EventType uint8

EventType defines actions of events.

const (
	EventAddOrUpdate EventType = iota
	EventDelete
)

EventType support Add/Update and Delete. All events are idempotent.

type Group

type Group interface {
	GetSchema() *commonv1.Group
	StoreResource(resourceSchema ResourceSchema) (Resource, error)
	LoadResource(name string) (Resource, bool)
}

Group is the root node, allowing get resources from its sub nodes.

type MetadataEvent

type MetadataEvent struct {
	Metadata *commonv1.Metadata
	Typ      EventType
	Kind     EventKind
}

MetadataEvent is the syncing message between metadata repo and this framework.

type Repository

type Repository interface {
	Watcher()
	SendMetadataEvent(MetadataEvent)
	StoreGroup(groupMeta *commonv1.Metadata) (*group, error)
	LoadGroup(name string) (Group, bool)
	LoadResource(metadata *commonv1.Metadata) (Resource, bool)
	NotifyAll() (err error)
	Close()
}

Repository is the collection of several hierarchies groups by a "Group".

func NewRepository

func NewRepository(
	metadata metadata.Repo,
	repo discovery.ServiceRepo,
	l *logger.Logger,
	resourceSupplier ResourceSupplier,
	shardTopic bus.Topic,
	entityTopic bus.Topic,
) Repository

NewRepository return a new Repository.

type Resource

type Resource interface {
	GetIndexRules() []*databasev1.IndexRule
	GetTopN() []*databasev1.TopNAggregation
	MaxObservedModRevision() int64
	EntityLocator() partition.EntityLocator
	ResourceSchema
	io.Closer
}

Resource allows access metadata from a local cache.

type ResourceSchema

type ResourceSchema interface {
	GetMetadata() *commonv1.Metadata
}

ResourceSchema allows get the metadata.

type ResourceSpec

type ResourceSpec struct {
	Schema ResourceSchema
	// IndexRules are index rules bound to the Schema
	IndexRules []*databasev1.IndexRule
	// Aggregations are topN aggregation bound to the Schema, e.g. TopNAggregation
	Aggregations []*databasev1.TopNAggregation
}

ResourceSpec wraps required fields to open a resource.

type ResourceSupplier

type ResourceSupplier interface {
	OpenResource(shardNum uint32, db tsdb.Supplier, spec ResourceSpec) (Resource, error)
	ResourceSchema(metdata *commonv1.Metadata) (ResourceSchema, error)
	OpenDB(groupSchema *commonv1.Group) (tsdb.Database, error)
}

ResourceSupplier allows open a resource and its embedded tsdb.

Jump to

Keyboard shortcuts

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