schema

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 19 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 DB added in v0.8.0

type DB interface {
	io.Closer
	UpdateOptions(opts *commonv1.ResourceOpts)
}

DB is the interface of a tsdb.

type EventKind

type EventKind uint8

EventKind defines category of events.

const (
	EventKindGroup EventKind = iota
	EventKindResource
	EventKindIndexRule
	EventKindIndexRuleBinding
)

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
	SupplyTSDB() io.Closer
}

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

type IndexListener added in v0.8.0

type IndexListener interface {
	OnIndexUpdate(index []*databasev1.IndexRule)
}

IndexListener listens to the index update.

type MetadataEvent

type MetadataEvent struct {
	Metadata ResourceSchema
	Typ      EventType
	Kind     EventKind
}

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

type Metrics added in v0.7.0

type Metrics struct {
	// contains filtered or unexported fields
}

Metrics is a collection of metrics.

func NewMetrics added in v0.7.0

func NewMetrics(factory *observability.Factory) *Metrics

NewMetrics creates a new Metrics.

type Repository

type Repository interface {
	Watcher()
	Init(schema.Kind) ([]string, []int64)
	SendMetadataEvent(MetadataEvent)
	LoadGroup(name string) (Group, bool)
	LoadAllGroups() []Group
	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,
	metrics *Metrics,
) Repository

NewPortableRepository return a new Repository without tsdb.

func NewRepository

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

NewRepository return a new Repository.

type Resource

type Resource interface {
	Schema() ResourceSchema
	Delegated() IndexListener
}

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(spec Resource) (IndexListener, error)
}

ResourceSchemaSupplier allows get a ResourceSchema from the metadata.

type ResourceSupplier

type ResourceSupplier interface {
	ResourceSchemaSupplier
	OpenDB(groupSchema *commonv1.Group) (DB, error)
}

ResourceSupplier allows open a resource and its embedded tsdb.

type Supplier added in v0.6.0

type Supplier interface {
	SupplyTSDB() io.Closer
}

Supplier allows open a tsdb.

Jump to

Keyboard shortcuts

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