storage

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package storage provides an interface for baur data storage implementations.

Index

Constants

View Source
const (
	NoLimit uint = 0
)

Variables

View Source
var ErrNotExist = errors.New("does not exist")

ErrNotExist indicates that a record does not exist

Functions

This section is empty.

Types

type ArtifactType

type ArtifactType string
const (
	ArtifactTypeDocker ArtifactType = "docker"
	ArtifactTypeFile   ArtifactType = "file"
)

type Field

type Field int

Field represents data fields that can be used in sort and filter operations

const (
	FieldUndefined Field = iota
	FieldApplicationName
	FieldTaskName
	FieldDuration
	FieldStartTime
	FieldID
	FieldInputString
	FieldInputFilePath
)

Defines the available data fields

func (Field) String

func (f Field) String() string

type Filter

type Filter struct {
	Field    Field
	Operator Op
	Value    interface{}
}

Filter specifies filter operatons for queries

type InputFile

type InputFile struct {
	Path   string
	Digest string
}

type InputString

type InputString struct {
	String string
	Digest string
}

type Inputs

type Inputs struct {
	Files   []*InputFile
	Strings []*InputString
}

type Op

type Op int

Op describes the filter operator

const (
	// OpEQ represents an equal (=) operator
	OpEQ Op = iota
	// OpGT represents a greater than (>) operator
	OpGT
	// OpLT represents a smaller than (<) operator
	OpLT
	// OpIN represents a In operator, works like the SQL IN operator, the
	// corresponding Value field in The filter struct must be a slice
	OpIN
)

func (Op) String

func (o Op) String() string

type Order

type Order int

Order specifies the sort order

const (
	// SortInvalid represents an invalid sort value
	SortInvalid Order = iota
	// OrderAsc sorts ascending
	OrderAsc
	// OrderDesc sorts descending
	OrderDesc
)

func OrderFromStr

func OrderFromStr(s string) (Order, error)

OrderFromStr converts a string to an Order

func (Order) String

func (s Order) String() string

type Output

type Output struct {
	Name      string
	Type      ArtifactType
	Digest    string
	SizeBytes uint64
	Uploads   []*Upload
}

type Result

type Result string
const (
	ResultSuccess Result = "success"
	ResultFailure Result = "failure"
)

type Sorter

type Sorter struct {
	Field Field
	Order Order
}

Sorter specifies how the result of queries should be sorted

func (*Sorter) String

func (s *Sorter) String() string

String return the string representation

type Storer

type Storer interface {
	Close() error

	// Init initializes a storage, e.g. creating the database scheme
	Init(context.Context) error
	// IsCompatible verifies that the storage is compatible with the baur version
	IsCompatible(context.Context) error

	SaveTaskRun(context.Context, *TaskRunFull) (id int, err error)
	LatestTaskRunByDigest(ctx context.Context, appName, taskName, totalInputDigest string) (*TaskRunWithID, error)

	TaskRun(ctx context.Context, id int) (*TaskRunWithID, error)
	// TaskRuns queries the storage for runs that match the filters.
	// A limit value of 0 will return all results.
	// The found results are passed in iterative manner to the callback
	// function. When the callback function returns an error, the iteration
	// stops.
	// When no matching records exist, the method returns ErrNotExist.
	TaskRuns(ctx context.Context,
		filters []*Filter,
		sorters []*Sorter,
		limit uint,
		callback func(*TaskRunWithID) error,
	) error

	// Inputs returns the inputs of a task run. If no records were found,
	// the method returns ErrNotExist.
	Inputs(ctx context.Context, taskRunID int) (*Inputs, error)
	Outputs(ctx context.Context, taskRunID int) ([]*Output, error)
}

Storer is an interface for storing and retrieving baur task runs

type TaskRun

type TaskRun struct {
	ApplicationName  string
	TaskName         string
	VCSRevision      string
	VCSIsDirty       bool
	StartTimestamp   time.Time
	StopTimestamp    time.Time
	TotalInputDigest string
	Result           Result
}

type TaskRunFull

type TaskRunFull struct {
	TaskRun
	Inputs  Inputs
	Outputs []*Output
}

type TaskRunWithID

type TaskRunWithID struct {
	ID int
	TaskRun
}

type Upload

type Upload struct {
	URI                  string
	UploadStartTimestamp time.Time
	UploadStopTimestamp  time.Time
	Method               UploadMethod
}

type UploadMethod

type UploadMethod string

UploadMethod is the method that was used to upload the object

const (
	UploadMethodS3             UploadMethod = "s3"
	UploadMethodDockerRegistry UploadMethod = "docker"
	UploadMethodFileCopy       UploadMethod = "filecopy"
)

Directories

Path Synopsis
Package postgres is a baur-storage implementation storing data in postgresql.
Package postgres is a baur-storage implementation storing data in postgresql.

Jump to

Keyboard shortcuts

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