processor

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package processor contains built-in post-query processors for the query engine: sqlite-backed merge and key-based reconciliation. Each processor self-registers via init(); consumers enable them with a blank import:

import _ "github.com/flanksource/commons-db/query/processor"

Index

Constants

View Source
const (
	ReconAdded     = "added"
	ReconRemoved   = "removed"
	ReconChanged   = "changed"
	ReconUnchanged = "unchanged"

	// ReconStatusColumn holds the per-row reconciliation status.
	ReconStatusColumn = "_recon_status"

	// ReconChangesColumn holds a map of changed columns -> {from,to} for
	// rows with status "changed".
	ReconChangesColumn = "_recon_changes"
)

Reconciliation status values written to the ReconStatusColumn.

Variables

This section is empty.

Functions

func Merge

func Merge(ctx context.Context, mergeSQL string, sets ...ResultSet) ([]query.Row, error)

Merge loads each ResultSet into an in-memory SQLite database as a table, then runs mergeSQL (an arbitrary join/aggregation across those tables) and returns the resulting rows. Ported from duty/dataquery/sqlite.go.

func Recon

func Recon(baseline, target []query.Row, opts ReconOptions) ([]query.Row, error)

Recon reconciles a target result set against a baseline, keyed by opts.Key. Each returned row is the target row (or the baseline row, for removals) plus a ReconStatusColumn of added/removed/changed/unchanged. Changed rows also carry a ReconChangesColumn mapping each differing column to {from, to}.

Pure logic — no database required.

Types

type ReconOptions

type ReconOptions struct {
	// Key is the set of columns that uniquely identify a row across both sets.
	Key []string

	// Compare restricts which columns are compared for the "changed" status.
	// When empty, all non-key columns present in either row are compared.
	Compare []string
}

ReconOptions configures a reconciliation.

type ResultSet

type ResultSet struct {
	Name string
	Rows []query.Row
}

ResultSet pairs a table name with the rows to load into the merge database.

Jump to

Keyboard shortcuts

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