schema

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 25 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 CachedGroupNames added in v0.11.0

func CachedGroupNames(repo Repository) []string

CachedGroupNames lists the names of every group the repository currently caches, so an all-groups snapshot request can enumerate without a roster.

func CollectSchemaSnapshot added in v0.11.0

func CollectSchemaSnapshot(
	repo Repository,
	group, resourceKind string,
	view ResourceViewer,
) ([]*databasev1.ObjectSnapshot, []*databasev1.IndexRule, error)

CollectSchemaSnapshot returns a node's cache and runtime schema BODIES for every object it holds in the group, as ObjectSnapshots. Unlike CollectSchemaState it ships no fingerprints: the FODC agent hashes the bodies on receive, keeping the hash algorithm and suppression policy out of the data path.

The same lock-free rationale as CollectSchemaState applies: the maps are read without the write path's mutex, so a concurrent watch event can tear the read; the agent's two-round suppression absorbs it. Callers that need a consistent view snapshot the resource list under a read lock before calling.

Types

type DB added in v0.8.0

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

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
	DeleteRevision int64 // non-zero only for EventDelete; carries the tombstone mod_revision
	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)
	LoadAllResources(group string) []Resource
	LoadAllIndexRules(group string) []*databasev1.IndexRule
	IndexRules(resourceSchema ResourceSchema) []*databasev1.IndexRule
	LatestModRevision() int64
	Close()
	StopCh() <-chan struct{}
	DropGroup(groupName string) error
}

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)
	// ResolveResourceOpts returns the ResourceOpts that should drive the tsdb for this
	// supplier's node: a data supplier resolves the matched lifecycle stage's
	// interval/ttl/shardNum, a liaison/queue supplier returns the group default. It lets
	// a group UpdateOptions apply the same stage-resolved values that OpenDB used, instead
	// of silently overwriting them with the group default.
	ResolveResourceOpts(groupSchema *commonv1.Group) *commonv1.ResourceOpts
}

ResourceSupplier allows open a resource and its embedded tsdb.

type ResourceView added in v0.11.0

type ResourceView struct {
	Cached       proto.Message
	Runtime      proto.Message
	Name         string
	RuntimeRules []*databasev1.IndexRule
}

ResourceView is one resource's cache and runtime views. Runtime is nil when the resource is not materialized.

type ResourceViewer added in v0.11.0

type ResourceViewer func(Resource) (ResourceView, bool)

ResourceViewer extracts the snapshot views of a resource. It returns false when the resource is not of the caller's catalog type. This is the only catalog-specific part of snapshot collection: IndexListener exposes only OnIndexUpdate, so reaching the runtime view needs a type assertion that only the owning package can make.

type RevisionRepository added in v0.11.0

type RevisionRepository interface {
	Repository
	ResourceRevision(kind schema.Kind, group, name string) (int64, bool)
	IsAbsent(kind schema.Kind, group, name string) bool
}

RevisionRepository extends Repository with per-key revision-query methods used by the write/query gates and the barrier implementation.

type Supplier added in v0.6.0

type Supplier interface {
	SupplyTSDB() io.Closer
}

Supplier allows open a tsdb.

Directories

Path Synopsis
Package registry holds the per-node aggregator that routes barrier and node-status RPC lookups to the same per-service schema-repo caches the query executor consults.
Package registry holds the per-node aggregator that routes barrier and node-status RPC lookups to the same per-service schema-repo caches the query executor consults.

Jump to

Keyboard shortcuts

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