sync

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sync pulls data from any omniroadmap provider into a Store, applying per-tenant fieldmap enrichment along the way. The engine is provider-agnostic and store-agnostic: it works identically against a live-API provider (aha, productboard, jpd) or a cache-backed one (aha-studio), and against the Dolt store or a test fake.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Kinds restricts which item kinds to sync; empty means every kind the
	// provider supports.
	Kinds []provider.ItemKind

	// Fieldmap, when set, maps tenant-specific custom fields onto
	// Item.MoSCoW / Item.RICE before storage.
	Fieldmap *fieldmap.Mapping

	// PerPage is the page size for provider list calls (default 100).
	PerPage int
}

Options configures a sync run.

type Report

type Report struct {
	Provider            string
	ItemCounts          map[provider.ItemKind]int
	ReleaseCount        int
	CustomFieldDefCount int
}

Report summarizes a completed sync run.

func Run

func Run(ctx context.Context, s Store, p provider.Provider, opts Options) (*Report, error)

Run syncs one provider into the store: items per kind (paginated, with fieldmap enrichment), releases and custom field definitions when supported, sync metadata per kind, and one final Commit.

func (*Report) TotalItems

func (r *Report) TotalItems() int

TotalItems returns the total item count across kinds.

type Store

type Store interface {
	UpsertItems(ctx context.Context, items []provider.Item) error
	UpsertReleases(ctx context.Context, releases []provider.Release) error
	UpsertCustomFieldDefinitions(ctx context.Context, providerName string, defs []provider.CustomFieldDefinition) error
	SetSyncMeta(ctx context.Context, providerName, kind string, lastSync time.Time, count int) error
	// Commit finalizes a sync run (a Dolt commit for the real store; no-op
	// acceptable for others).
	Commit(ctx context.Context, message string) error
}

Store is the persistence contract the engine writes to. *store.DoltStore implements it; tests use a fake.

Jump to

Keyboard shortcuts

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