schemasync

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package schemasync exports the schema of the selected groups through the liaison's registry services into the artifact's schema/<kind>.jsonl files.

Index

Constants

View Source
const (
	KindGroup            = "group"
	KindStream           = "stream"
	KindMeasure          = "measure"
	KindTrace            = "trace"
	KindProperty         = "property"
	KindIndexRule        = "indexRule"
	KindIndexRuleBinding = "indexRuleBinding"
	KindTopNAggregation  = "topNAggregation"
)

The schema kinds, which are also the file base names below Dir.

View Source
const Dir = "schema"

Dir is the schema directory below the artifact root.

Variables

DataKinds are the kinds of the resources a CSV file binds its columns to: a node encodes a unit of a group with every resource of these kinds in the group and reports their mod revisions. Index rules, their bindings, Top-N aggregations and the group itself are not among them.

Kinds lists every schema kind in file order.

Functions

func DiffFingerprints

func DiffFingerprints(recorded, live map[string]string) []string

DiffFingerprints spells, sorted, every resource whose fingerprint differs between recorded and live, or that only one of them holds; nil when they are equal.

func ListGroup

func ListGroup(ctx context.Context, conn *grpc.ClientConn, g *commonv1.Group, visit func(kind string, m proto.Message) error) error

ListGroup lists every resource of a group through conn, only the kinds its catalog can hold, and calls visit with the kind and the resource; the group itself is not visited. A listing or visit failure stops it.

func Live

func Live(ctx context.Context, conn *grpc.ClientConn, groups []*commonv1.Group) (map[string]string, error)

Live lists every resource of groups through conn, as Export does, without writing anything, and returns their Fingerprints.

func Restrict

func Restrict(live, recorded map[string]string) (known map[string]string, added []string)

Restrict splits live into the fingerprints of the resources recorded holds and, sorted, the keys of those it lacks: the resources added since recorded was taken.

func Select

func Select(fingerprints map[string]string, kinds, groups []string) map[string]string

Select keeps the fingerprints of the resources of kinds that belong to groups.

Types

type File

type File struct {
	// Path is relative to the artifact root, slash separated: "schema/<kind>.jsonl".
	Path  string
	Bytes uint64
	CRC32 uint32
}

File is one written schema file.

type Result

type Result struct {
	Measures []*databasev1.Measure
	Files    []File
	// contains filtered or unexported fields
}

Result is what Export wrote, with the decoded measures the exporter needs afterwards.

func Export

func Export(ctx context.Context, conn *grpc.ClientConn, groups []*commonv1.Group, dir string) (*Result, error)

Export lists every resource of groups through conn and writes one protojson line per resource, unpopulated fields included, to dir/schema/<kind>.jsonl. Only the kinds a group's catalog can hold are listed. Every kind gets a file, possibly empty, so the artifact's file set does not depend on the data. Files are 0600 and the directory 0700.

func Load

func Load(dir string) (*Result, error)

Load rebuilds the Result of an Export from the schema files it wrote below dir/schema: the files with their sizes and CRC-32, the mod revisions, the fingerprints and the measures. A resumed export uses it instead of listing the registries again, so the schema it checks the new files against is the one the artifact holds.

func (*Result) Fingerprints

func (r *Result) Fingerprints() map[string]string

Fingerprints maps every resource of the schema, keyed "<kind> <group>/<name>" ("group <name>" for a group), to what tells its versions apart: "revision <n>", its metadata's mod revision, which the registry sets on every create and every update that changes it, of any kind. Two schemas with the same fingerprints are the same schema. The content itself is not compared: a resource read back from a schema file lacks the fields this bydbctl does not know, which the one read from the registry keeps.

func (*Result) GroupRevisions

func (r *Result) GroupRevisions(catalog commonv1.Catalog, group string) map[string]int64

GroupRevisions returns the mod revision the registry reported for every stream, measure, trace or property resource of a group, keyed by resource name.

Jump to

Keyboard shortcuts

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