go.bigb.es/curator

v1.0.0
Doc Versions Source

Functions

f func ImportFromConfigFile

src
func ImportFromConfigFile(st *Store, path string) (modules int, patterns int, err error)

ImportFromConfigFile reads an old config.json and imports modules and patterns into the store.

f func VerifyModule

src
func VerifyModule(repo string, timeout time.Duration) error

VerifyModule checks that a git repository is accessible via git ls-remote.

f func VerifyPattern

src
func VerifyPattern(pattern string) error

VerifyPattern checks that a regex pattern compiles.

Types

T type ModuleResolver

src
type ModuleResolver interface {
	ResolveModule(name string) (config.Module, bool)
}

ModuleResolver abstracts module lookup for the server.

T type ModuleRow

src
type ModuleRow struct {
	Name      string `json:"name"`
	VCS       string `json:"vcs"`
	Repo      string `json:"repo"`
	Web       string `json:"web"`
	Private   bool   `json:"private"`
	CreatedAt string `json:"created_at,omitempty"`
}

ModuleRow represents a module stored in the database.

T type PatternRow

src
type PatternRow struct {
	ID        int64  `json:"id"`
	Pattern   string `json:"pattern"`
	VCS       string `json:"vcs"`
	Repo      string `json:"repo"`
	Web       string `json:"web"`
	Private   bool   `json:"private"`
	Priority  int    `json:"priority"`
	CreatedAt string `json:"created_at,omitempty"`
}

PatternRow represents a module pattern stored in the database.

T type Store

src
type Store struct {
	// contains filtered or unexported fields
}

Store is a database-backed module store implementing ModuleResolver. It supports both SQLite and PostgreSQL backends.

f func Open

src
func Open(driver, dsn string) (*Store, error)

Open opens a database with the given driver and DSN, then runs migrations. Supported drivers: "sqlite", "postgres".

For SQLite the DSN is a file path (WAL mode and busy timeout are set automatically). For PostgreSQL the DSN is a connection string (e.g. "postgres://user:pass@host/db?sslmode=disable").

m func (*Store) AddModule

src
func (st *Store) AddModule(m ModuleRow) error

AddModule adds a module to the database.

m func (*Store) AddPattern

src
func (st *Store) AddPattern(p PatternRow) error

AddPattern adds a module pattern to the database and refreshes the cache.

m func (*Store) Close

src
func (st *Store) Close() error

Close closes the database connection.

m func (*Store) DeleteModule

src
func (st *Store) DeleteModule(name string) error

DeleteModule removes a module from the database.

m func (*Store) DeletePattern

src
func (st *Store) DeletePattern(id int64) error

DeletePattern removes a module pattern and refreshes the cache.

m func (*Store) GetHashes

src
func (st *Store) GetHashes(ctx context.Context, ids []int64) ([][]byte, error)

GetHashes returns hashes for the given IDs, in the order requested.

m func (*Store) GetRecords

src
func (st *Store) GetRecords(ctx context.Context, startID, count int64) ([][]byte, error)

GetRecords returns record data for IDs [startID, startID+count).

m func (*Store) ListModules

src
func (st *Store) ListModules() ([]ModuleRow, error)

ListModules returns all modules.

m func (*Store) ListPatterns

src
func (st *Store) ListPatterns() ([]PatternRow, error)

ListPatterns returns all module patterns ordered by priority.

m func (*Store) LookupRecord

src
func (st *Store) LookupRecord(ctx context.Context, key string) (int64, bool, error)

LookupRecord returns the record ID for a key, or found=false if not present.

m func (*Store) ModuleCount

src
func (st *Store) ModuleCount() int

ModuleCount returns the total number of configured modules (exact + patterns).

m func (*Store) RecordCount

src
func (st *Store) RecordCount(ctx context.Context) (int64, error)

RecordCount returns the total number of sumdb records.

m func (*Store) ResolveModule

src
func (st *Store) ResolveModule(name string) (config.Module, bool)

ResolveModule looks up a module by name: exact match first, then patterns.

m func (*Store) SaveRecord

src
func (st *Store) SaveRecord(ctx context.Context, recordID int64, key string, data []byte, hashStartID int64, hashes [][]byte) error

SaveRecord inserts a record and its hashes in a single transaction.

T type SumdbStore

src
type SumdbStore interface {
	// SaveRecord atomically persists a new record and its associated hashes.
	SaveRecord(ctx context.Context, recordID int64, key string, data []byte, hashStartID int64, hashes [][]byte) error

	// GetRecords returns record data for IDs [startID, startID+count).
	GetRecords(ctx context.Context, startID, count int64) ([][]byte, error)

	// GetHashes returns hashes for the given IDs, in the order requested.
	GetHashes(ctx context.Context, ids []int64) ([][]byte, error)

	// LookupRecord returns the record ID for a key, or found=false.
	LookupRecord(ctx context.Context, key string) (id int64, found bool, err error)

	// RecordCount returns the total number of sumdb records.
	RecordCount(ctx context.Context) (int64, error)
}

SumdbStore is the persistence interface for sumdb transparency log state.