Documentation
¶
Overview ¶
Package catalog is the commands over the local search catalog: ingest builds it from the repo's context sources, search queries it, and lineage traces fields through it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Ingest = command.Define(command.Def[IngestInput, string]{ Name: "ingest", Short: "Build the local search catalog from the repo's context sources", Idempotent: true, Timeout: 30 * time.Minute, Needs: func(IngestInput) command.Sidecars { return command.Sidecars{Node: true, CanalQuery: true} }, Run: func(ctx context.Context, cc command.CommandContext, in IngestInput) (string, error) { if err := command.RequireSidecars(cc, command.Sidecars{Node: true, CanalQuery: true}); err != nil { return "", err } return ingest.Run(ctx, cc.Clients.Node, cc.Clients.CanalQuery, cc.Repo, in.Source) }, })
Ingest builds the local search catalog from context sources.
var Lineage = command.Define(command.Def[LineageInput, LineageResult]{ Name: "lineage", Short: "Trace fields through the local catalog to what each one is built from", Long: "Trace each field through the local catalog to the fields, models, and sources it is built from. " + "Return each field's lineage as a diagram to draw, with cards in layers from upstream to downstream, and the links between them.", ReadOnly: true, Idempotent: true, Needs: func(LineageInput) command.Sidecars { return command.Sidecars{Node: true, CanalQuery: true} }, Check: LineageInput.check, Run: func(ctx context.Context, cc command.CommandContext, in LineageInput) (LineageResult, error) { if err := command.RequireSidecars(cc, command.Sidecars{Node: true, CanalQuery: true}); err != nil { return LineageResult{}, err } targets := in.targets() res, err := cc.Clients.Node.CatalogLineage(ctx, anfranode.CatalogLineageRequest{ Context: anfranode.CatalogContextOf(cc.Repo, cc.Clients.CanalQuery.BaseURL()), Targets: targets, Limit: in.Limit, Offset: in.Offset, }) if err != nil { return LineageResult{}, err } if len(res.Results) != len(targets) { return LineageResult{}, fmt.Errorf("anfra-node traced %d fields, asked %d", len(res.Results), len(targets)) } out := LineageResult{Results: make([]FieldLineage, len(targets))} for i, r := range res.Results { if r.Target != targets[i] { return LineageResult{}, fmt.Errorf("anfra-node traced %s.%s where %s.%s was asked", r.Target.Parent, r.Target.Child, targets[i].Parent, targets[i].Child) } out.Results[i] = FieldLineage{Target: in.Targets[i], Query: r.Query, Diagram: r.Diagram, Error: r.Error} } return out, nil }, })
Lineage traces fields through the local catalog: what each one is built from.
var Search = command.Define(command.Def[SearchInput, anfranode.CatalogSearchResult]{ Name: "search", Short: "Search the local catalog", ReadOnly: true, Needs: func(SearchInput) command.Sidecars { return command.Sidecars{Node: true, CanalQuery: true} }, Check: SearchInput.check, Run: func(ctx context.Context, cc command.CommandContext, in SearchInput) (anfranode.CatalogSearchResult, error) { if err := command.RequireSidecars(cc, command.Sidecars{Node: true, CanalQuery: true}); err != nil { return nil, err } return search.Run(ctx, cc.Clients.Node, cc.Clients.CanalQuery, cc.Repo, search.Request{ Query: strings.TrimSpace(strings.Join(in.Query, " ")), Limit: in.Limit, Offset: in.Offset, }) }, })
Search searches the local catalog.
Functions ¶
This section is empty.
Types ¶
type FieldLineage ¶ added in v0.9.0
type FieldLineage struct {
Target anfranode.LineageTarget `json:"target" doc:"the field, as asked"`
Query string `` /* 152-byte string literal not displayed */
Diagram *anfranode.Diagram `json:"diagram,omitempty" doc:"the field's lineage. Absent when error is set."`
Error string `json:"error,omitempty" doc:"why the field's lineage could not be traced"`
}
FieldLineage is one field's lineage, or why it could not be traced.
type IngestInput ¶
type IngestInput struct {
Source string `json:"source,omitempty" short:"s" doc:"the context source to ingest, every source by default"`
}
IngestInput is ingest's input.
func (IngestInput) TransformSchema ¶
type LineageInput ¶ added in v0.9.0
type LineageInput struct {
Targets []anfranode.LineageTarget `` /* 138-byte string literal not displayed */
Limit int `json:"limit,omitempty" minimum:"1" doc:"the most upstream entities to return per field, all of them by default"`
Offset int `json:"offset,omitempty" minimum:"0" doc:"skip this many upstream entities first, to page with limit"`
}
LineageInput is lineage's input: the fields to trace, and the page of what each one is built from.
func (LineageInput) TransformSchema ¶ added in v0.9.0
type LineageResult ¶ added in v0.9.0
type LineageResult struct {
Results []FieldLineage `json:"results"`
}
LineageResult is lineage's answer: each field's lineage, in the order of the fields asked.
type SearchInput ¶
type SearchInput struct {
Query []string `json:"query,omitempty" cli:"positional" doc:"search query"`
Limit int `json:"limit,omitempty" minimum:"1" maximum:"100" doc:"the most entities to return, 50 by default"`
Offset int `json:"offset,omitempty" minimum:"0" doc:"skip this many entities first, to page with limit"`
}
SearchInput is search's input: the query, and the page of what it matches.