datastore

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PropertyTypeUnknown = iota
	PropertyTypeInt
	PropertyTypeDouble
	PropertyTypeString
	PropertyTypeStruct
	PropertyTypeProto
	PropertyTypeBoolean
)

Variables

View Source
var (
	ErrCreatingDatastore    = errors.New("error creating datastore")
	ErrUnsupportedDatastore = errors.New("unsupported datastore type")
)

Functions

func Register added in v0.3.2

func Register(t string, fn func(config any) (Connector, error))

Types

type ArtifactTypeMap added in v0.3.2

type ArtifactTypeMap map[string]int32

ArtifactTypeMap maps artifact type names to IDs

type Connector

type Connector interface {
	Type() string
	Connect(spec *Spec) (RepoSet, error)
}

func NewConnector

func NewConnector(t string, config any) (Connector, error)

type ContextTypeMap added in v0.3.2

type ContextTypeMap map[string]int32

ContextTypeMap maps context type names to IDs

type ExecutionTypeMap added in v0.3.2

type ExecutionTypeMap map[string]int32

ExecutionTypeMap maps execution type names to IDs

type PropertyType added in v0.3.2

type PropertyType int32

PropertyType is the data type of a property's value.

type RepoSet added in v0.3.2

type RepoSet interface {
	// TypeMap returns a map of type names to IDs
	TypeMap() map[string]int32

	// Repository returns a repository instance of the specified type.
	Repository(t reflect.Type) (any, error)
}

RepoSet holds repository implementions.

type Spec added in v0.3.2

type Spec struct {
	// Maps artifact type names to an initializer.
	ArtifactTypes map[string]*SpecType

	// Maps context type names to an initializer.
	ContextTypes map[string]*SpecType

	// Maps execution type names to an initializer.
	ExecutionTypes map[string]*SpecType

	// Any repo initialization functions that don't map to a type can be
	// added here.
	Others []any
}

Spec is the specification for the datastore. Each entry

func NewSpec added in v0.3.2

func NewSpec() *Spec

NewSpec returns an empty Spec instance.

func (*Spec) AddArtifact added in v0.3.2

func (s *Spec) AddArtifact(name string, t *SpecType) *Spec

AddArtifact adds an artifact type to the spec.

func (*Spec) AddContext added in v0.3.2

func (s *Spec) AddContext(name string, t *SpecType) *Spec

AddContext adds a context type to the spec.

func (*Spec) AddExecution added in v0.3.2

func (s *Spec) AddExecution(name string, t *SpecType) *Spec

AddExecution adds an execution type to the spec.

func (*Spec) AddOther added in v0.3.2

func (s *Spec) AddOther(initFn any) *Spec

AddOther adds a repo initializer to the spec.

func (*Spec) AllNames added in v0.3.2

func (s *Spec) AllNames() []string

AllNames returns all the type names in the spec.

type SpecType added in v0.3.2

type SpecType struct {
	// InitFn is a pointer to an initialization function that returns the
	// repository instance and an optional error.
	//
	// Data Store implementations must pass arguments to the initialization
	// functions that are required by the repository (database handles,
	// HTTP clients, etc.) and should also provide values for the following
	// types:
	//
	//   - int64: type id
	//   - ArtifactTypeMap: Map of all artifact names to type IDs
	//   - ContextTypeMap: Map of all context names to type IDs
	//   - ExecutionTypeMap: Map of all execution names to type IDs
	InitFn any

	// Defined (non-custom) properties of the type.
	Properties map[string]PropertyType
}

SpecType is a single type in the spec.

func NewSpecType added in v0.3.2

func NewSpecType(initFn any) *SpecType

NewSpecType creates a SpecType instance.

func (*SpecType) AddBoolean added in v0.3.2

func (st *SpecType) AddBoolean(name string) *SpecType

AddBoolean adds a boolean property to the type spec.

func (*SpecType) AddDouble added in v0.3.2

func (st *SpecType) AddDouble(name string) *SpecType

AddDouble adds a double property to the type spec.

func (*SpecType) AddInt added in v0.3.2

func (st *SpecType) AddInt(name string) *SpecType

AddInt adds an int property to the type spec.

func (*SpecType) AddProto added in v0.3.2

func (st *SpecType) AddProto(name string) *SpecType

AddProto adds a proto property to the type spec.

func (*SpecType) AddString added in v0.3.2

func (st *SpecType) AddString(name string) *SpecType

AddString adds a string property to the type spec.

func (*SpecType) AddStruct added in v0.3.2

func (st *SpecType) AddStruct(name string) *SpecType

AddStruct adds a struct property to the type spec.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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