vecsync

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package vecsync defines foundational types for SCN-based synchronization between an upstream SQL database (authoritative shadow tables and vec_shadow_log) and downstream SQLite replicas. Higher-level sync coordinators will live in this package incrementally; at this stage it contains the shared metadata structures used by both the ingestion/log producer and the replicator.

Index

Constants

View Source
const (
	// DefaultLogTable is the upstream change-log table that captures row-level SCN events.
	DefaultLogTable = "vec_shadow_log"

	// DefaultSeqTable stores the next SCN per dataset on the upstream database.
	DefaultSeqTable = "vec_dataset_scn"
)

Variables

This section is empty.

Functions

func LogTableDDL

func LogTableDDL() string

LogTableDDL returns the DDL for vec_shadow_log, which upstream databases populate via triggers whenever the shadow table changes.

func MySQLShadowLogTriggers

func MySQLShadowLogTriggers(shadowTable, seqTable, logTable string) []string

MySQLShadowLogTriggers returns AFTER INSERT/UPDATE/DELETE trigger definitions that populate vec_shadow_log with JSON payloads (hex-encoded embeddings) and per-dataset SCNs. Callers are responsible for wrapping the statements with an appropriate DELIMITER when executing them.

func SQLiteShadowLogTriggers

func SQLiteShadowLogTriggers(shadowTable, seqTable, logTable string) []string

SQLiteShadowLogTriggers returns the trigger DDL statements required to capture inserts, updates, and deletes against a shadow table into vec_shadow_log using SQLite syntax. The payload is serialized as JSON with a hex-encoded embedding.

func SeqTableDDL

func SeqTableDDL() string

SeqTableDDL returns the DDL for tracking next SCN per dataset (optional helper).

func ShadowTableDDL

func ShadowTableDDL(table string) string

ShadowTableDDL returns the base DDL snippet for upstream shadow tables with SCN support. Callers can embed this SQL when creating dataset-aware document stores. The DDL assumes SQLite/MySQL-compatible syntax; adapt as needed for other engines.

Types

type Config

type Config struct {
	// DatasetID identifies the dataset slice being synchronized.
	DatasetID string

	// ShadowTable is the fully-qualified shadow table name (e.g., "main.shadow_vec_docs").
	ShadowTable string

	// BatchSize controls how many log entries to fetch/apply per sync iteration.
	BatchSize int
}

Config captures the settings needed to perform SCN-based replication from an upstream SQL database into a local SQLite shadow table. Subsequent sync components will build on this struct.

type LogEntry

type LogEntry struct {
	DatasetID   string
	ShadowTable string
	SCN         int64
	Op          string
	DocumentID  string
	Payload     []byte
	CreatedAt   time.Time
}

LogEntry mirrors a single row in vec_shadow_log on the upstream database. It conveys dataset-scoped document changes to downstream replicas.

type SyncState

type SyncState struct {
	DatasetID   string
	ShadowTable string
	LastSCN     int64
	UpdatedAt   time.Time
}

SyncState describes the latest SCN applied locally for a given dataset/shadow pair. It corresponds to rows in vec_sync_state on downstream SQLite replicas.

Jump to

Keyboard shortcuts

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