registry

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: 3 Imported by: 0

Documentation

Overview

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. Living in its own package lets banyand/metadata expose the registry via metadata.Service without importing pkg/schema, which would create a cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaybeRegister

func MaybeRegister(reg *NodeRepoRegistry, kinds schema.Kind, repo any)

MaybeRegister registers repo with reg under the given kinds when reg is non-nil and repo satisfies RevisionRepository. Service constructors hold the schemaRepo as a Repository interface (pkg/schema.Repository); the concrete value is *pkg/schema.schemaRepo, which implements RevisionRepository — so a type assertion at registration time is safe in production and fails closed for in-memory test fakes that only implement the base Repository surface.

Types

type NodeRepoRegistry

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

NodeRepoRegistry aggregates per-service RevisionRepository instances on a single node (liaison or data). Each banyand service (measure, stream, trace, …) registers its schemaRepo during PreRun with a kind bitmask describing the kinds the repo tracks. The registry routes per-key barrier and node-status lookups (GetKeyRevisions / GetAbsentKeys) to the same caches the executor consults during query plan execution, so a positive answer from ResourceRevision / IsAbsent implies the registered repo for that kind has applied the revision and any executor cache the node exposes is at least at that point. This is the load-bearing prerequisite for the Phase 2 single-cache invariant — without it the cluster barrier would certify a cache the data-node executor never reads.

The aggregate global watermark belongs to the schemaCache (notifiedModRevision), not to the registry: per-service schemaRepos filter events by catalog (pkg/schema/init.go), so their per-repo latestModRevision is incomparable across repos and a min/max aggregate cannot represent a meaningful node-wide watermark.

Safe for concurrent registration during PreRun and concurrent lookup.

func NewNodeRepoRegistry

func NewNodeRepoRegistry() *NodeRepoRegistry

NewNodeRepoRegistry returns an empty registry ready for service registration.

func (*NodeRepoRegistry) Empty

func (r *NodeRepoRegistry) Empty() bool

Empty reports whether any repo has been registered. GetAbsentKeys uses this to route through the schemaCache on a node where no per-service schemaRepo runs (e.g. a property-only metadata host).

func (*NodeRepoRegistry) HasKind

func (r *NodeRepoRegistry) HasKind(kind schema.Kind) bool

HasKind reports whether at least one repo is registered for the given kind. The node-status server uses this to route per-key lookups: kinds with a registered repo go through the registry; kinds without (TopN, Property) fall through to the property schemaCache.

func (*NodeRepoRegistry) IsAbsent

func (r *NodeRepoRegistry) IsAbsent(kind schema.Kind, group, name string) bool

IsAbsent returns true when no repo registered for the kind holds the given (group, name). A kind with no registered repo is reported absent — the AwaitSchemaDeleted barrier reads this as "the deletion has already been observed" only if the kind genuinely has no owner on this node. Wire TopN/Property kinds through the schemaCache path; do not infer absence from this registry for those.

func (*NodeRepoRegistry) Register

func (r *NodeRepoRegistry) Register(kinds schema.Kind, repo RevisionRepository)

Register associates a RevisionRepository with one or more kinds. The kinds argument is a bitmask of schema.Kind values; the registry walks each set bit and indexes the repo against that kind. Re-registering the same (kind, repo) pair is a no-op so PreRun is idempotent. A nil repo or empty kind mask is silently dropped.

func (*NodeRepoRegistry) ResourceRevision

func (r *NodeRepoRegistry) ResourceRevision(kind schema.Kind, group, name string) (int64, bool)

ResourceRevision routes the lookup to repos registered against the given kind and returns the first match. Returns (0, false) when no repo is registered for the kind or no registered repo holds the resource — the same shape the per-service schemaRepo.ResourceRevision returns for an unknown key, so the barrier and node-status RPC can fall through unchanged.

type RevisionRepository

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

RevisionRepository is the read surface a per-service schema repo exposes to the registry. The schemaRepo type in pkg/schema implements this interface; keeping the interface here (alongside the registry) instead of importing pkg/schema avoids a dependency cycle through banyand/metadata.

Jump to

Keyboard shortcuts

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