storage

package
v0.0.0-...-31e5321 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a requested key does not exist.

Functions

func Add

func Add(driverName string, init InitFunc)

func Each

func Each(f func(string, InitFunc))

Types

type Driver

type Driver interface {
	Close() error
	Set(ctx context.Context, prefix string, payload any) error
	Get(ctx context.Context, prefix string) (Payload, error)
	GetAll(ctx context.Context, prefix string, fields []string) (Results, error)

	// Pipeline CRUD operations
	SavePipeline(ctx context.Context, name, content, driverDSN string) (*Pipeline, error)
	GetPipeline(ctx context.Context, id string) (*Pipeline, error)
	ListPipelines(ctx context.Context) ([]Pipeline, error)
	DeletePipeline(ctx context.Context, id string) error

	// Pipeline run operations
	SaveRun(ctx context.Context, pipelineID string) (*PipelineRun, error)
	GetRun(ctx context.Context, runID string) (*PipelineRun, error)
	ListRunsByPipeline(ctx context.Context, pipelineID string) ([]PipelineRun, error)
	UpdateRunStatus(ctx context.Context, runID string, status RunStatus, errorMessage string) error

	// Resource version operations
	SaveResourceVersion(ctx context.Context, resourceName string, version map[string]string, jobName string) (*ResourceVersion, error)
	GetLatestResourceVersion(ctx context.Context, resourceName string) (*ResourceVersion, error)
	ListResourceVersions(ctx context.Context, resourceName string, limit int) ([]ResourceVersion, error)
	GetVersionsAfter(ctx context.Context, resourceName string, afterVersion map[string]string) ([]ResourceVersion, error)
}

type InitFunc

type InitFunc func(string, string, *slog.Logger) (Driver, error)

func GetFromDSN

func GetFromDSN(dsn string) (InitFunc, bool)

type Payload

type Payload map[string]any

func (*Payload) Scan

func (p *Payload) Scan(sqlValue any) error

func (*Payload) Value

func (p *Payload) Value() (driver.Value, error)

type Pipeline

type Pipeline struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Content   string    `json:"content"`
	DriverDSN string    `json:"driver_dsn"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Pipeline represents a stored pipeline definition.

type PipelineRun

type PipelineRun struct {
	ID           string     `json:"id"`
	PipelineID   string     `json:"pipeline_id"`
	Status       RunStatus  `json:"status"`
	StartedAt    *time.Time `json:"started_at,omitempty"`
	CompletedAt  *time.Time `json:"completed_at,omitempty"`
	ErrorMessage string     `json:"error_message,omitempty"`
	CreatedAt    time.Time  `json:"created_at"`
}

PipelineRun represents an execution of a pipeline.

type ResourceVersion

type ResourceVersion struct {
	ID           int64             `json:"id"`
	ResourceName string            `json:"resource_name"`
	Version      map[string]string `json:"version"`
	FetchedAt    time.Time         `json:"fetched_at"`
	JobName      string            `json:"job_name,omitempty"` // For passed constraints
}

ResourceVersion represents a stored resource version.

type Result

type Result struct {
	ID      int     `db:"id"`
	Path    string  `db:"path"`
	Payload Payload `db:"payload"`
}

type Results

type Results []Result

func (Results) AsTree

func (results Results) AsTree() *Tree[Payload]

type RunStatus

type RunStatus string

RunStatus represents the status of a pipeline run.

const (
	RunStatusQueued  RunStatus = "queued"
	RunStatusRunning RunStatus = "running"
	RunStatusSuccess RunStatus = "success"
	RunStatusFailed  RunStatus = "failed"
)

type Tree

type Tree[T any] struct {
	Name     string     `json:"name"`
	Children []*Tree[T] `json:"children,omitempty"`
	Value    T          `json:"value,omitempty"`

	FullPath string `json:"full_path,omitempty"`
}

func NewTree

func NewTree[T any]() *Tree[T]

func (*Tree[T]) AddNode

func (p *Tree[T]) AddNode(name string, value T)

func (*Tree[T]) Flatten

func (p *Tree[T]) Flatten()

func (*Tree[T]) HasSingleChild

func (p *Tree[T]) HasSingleChild() bool

HasSingleChild checks if this path has exactly one child.

func (*Tree[T]) IsGroup

func (p *Tree[T]) IsGroup() bool

IsGroup determines if this path is a group (has children).

func (*Tree[T]) IsLeaf

func (p *Tree[T]) IsLeaf() bool

IsLeaf determines if this path is a leaf node (has no children).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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