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
- Variables
- func DiffFingerprints(recorded, live map[string]string) []string
- func ListGroup(ctx context.Context, conn *grpc.ClientConn, g *commonv1.Group, ...) error
- func Live(ctx context.Context, conn *grpc.ClientConn, groups []*commonv1.Group) (map[string]string, error)
- func Restrict(live, recorded map[string]string) (known map[string]string, added []string)
- func Select(fingerprints map[string]string, kinds, groups []string) map[string]string
- type File
- type Result
Constants ¶
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.
const Dir = "schema"
Dir is the schema directory below the artifact root.
Variables ¶
var DataKinds = []string{KindStream, KindMeasure, KindTrace, KindProperty}
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.
var Kinds = []string{KindGroup, KindStream, KindMeasure, KindTrace, KindProperty, KindIndexRule, KindIndexRuleBinding, KindTopNAggregation}
Kinds lists every schema kind in file order.
Functions ¶
func DiffFingerprints ¶
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.
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 ¶
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 ¶
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.