common

package module
v0.0.0-...-b191d09 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: EUPL-1.2 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrangeDataStoreWithTestSchema

func ArrangeDataStoreWithTestSchema(t *testing.T, ds DataStore)

ArrangeDataStoreWithTestSchema is a test helper to have a sensible but reasonably complex schema for unit testing. RH: TODO: this should be way bigger.

Types

type DataStore

type DataStore interface {
	// Name returns the name of the datastore type.
	Name() string

	// Reset clears the entire data store, both the schema and claims.
	// RH: ATTN: This method is useful for testing, but probably should not make it into production :)
	Reset() error

	// Schema returns the immutable data schema.
	Schema() model.Schema

	// AddLabelType creates a new label type definition in the data store.
	AddLabelType(labelType model.LabelType) error

	// AddClaimType create a new claim type definition in the data store.
	AddClaimType(model.ClaimType) error

	// AddClaim creates a new claim in the data store.
	AddClaim(claim model.Claim) error
	// GetClaim returns a single claim by id.
	// If the storage backend call is successful, but the claim doesn't exist, (nil, nil) is returned (so no error)
	GetClaim(id model.ClaimID) (model.Claim, error)
	// GetClaims returns an iterator over all claims in the data store, optionally filtered.
	// It returns a single-use iterator.
	GetClaims(filter *model.ClaimFilter) (iter.Seq[model.Claim], error)

	// SetLatestMigration sets the latest claim schema migration number applied
	SetLatestMigration(int, string) error
	// GetLatestMigration returns the latest claim schema migration number applied
	GetLatestMigration() (int, error)
}

DataStore is the interface to persist (or not) claim schema and data.

Jump to

Keyboard shortcuts

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