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: 14 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

This section is empty.

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
	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)
	Close()
	StopCh() <-chan struct{}
}

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

func NewPortableRepository added in v0.5.0

func NewPortableRepository(
	metadata metadata.Repo,
	l *logger.Logger,
	supplier ResourceSchemaSupplier,
) Repository

NewPortableRepository return a new Repository without tsdb.

func NewRepository

func NewRepository(
	metadata metadata.Repo,
	l *logger.Logger,
	resourceSupplier ResourceSupplier,
) Repository

NewRepository return a new Repository.

type Resource

type Resource interface {
	io.Closer
	IndexRules() []*databasev1.IndexRule
	TopN() []*databasev1.TopNAggregation
	Schema() ResourceSchema
	Delegated() io.Closer
}

Resource allows access metadata from a local cache.

type ResourceSchema

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

ResourceSchema allows get the metadata.

type ResourceSchemaSupplier added in v0.5.0

type ResourceSchemaSupplier interface {
	ResourceSchema(metadata *commonv1.Metadata) (ResourceSchema, error)
	OpenResource(shardNum uint32, db tsdb.Supplier, spec Resource) (io.Closer, error)
}

ResourceSchemaSupplier allows get a ResourceSchema from the metadata.

type ResourceSupplier

type ResourceSupplier interface {
	ResourceSchemaSupplier
	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