db

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AlgorithmExistsUnderDifferentProcessor = fmt.Errorf(
		"algorithm exists under a different processor",
	)
)

custom errors

Functions

This section is empty.

Types

type Algorithm

type Algorithm struct {
	ID                       int64
	Name                     string
	Version                  string
	ProcessorID              int64
	WindowTypeID             int64
	ResultType               ResultType
	Created                  pgtype.Timestamp
	Description              string
	SelfLookbackCount        int64
	SelfLookbackTimedelta    int64
	SelfLookbackGapCount     int64
	SelfLookbackGapTimedelta int64
}

type AlgorithmDependency

type AlgorithmDependency struct {
	ID                   int64
	FromAlgorithmID      int64
	ToAlgorithmID        int64
	FromWindowTypeID     int64
	ToWindowTypeID       int64
	FromProcessorID      int64
	ToProcessorID        int64
	Created              pgtype.Timestamp
	LookbackCount        int64
	LookbackTimedelta    int64
	LookbackGapCount     int64
	LookbackGapTimedelta int64
}

type AlgorithmExecutionPath

type AlgorithmExecutionPath struct {
	FinalAlgoID                  int64
	NumDependencies              int32
	AlgoIDPath                   string
	WindowTypeIDPath             string
	ProcIDPath                   string
	LookbackCountPath            string
	LookbackTimedeltaPath        string
	SelfLookbackCountPath        string
	SelfLookbackTimedeltaPath    string
	LookbackGapCountPath         string
	LookbackGapTimedeltaPath     string
	SelfLookbackGapCountPath     string
	SelfLookbackGapTimedeltaPath string
}

type AlgorithmState

type AlgorithmState string
const (
	AlgorithmStatePENDING         AlgorithmState = "PENDING"
	AlgorithmStatePROCESSING      AlgorithmState = "PROCESSING"
	AlgorithmStateSUCCEEDED       AlgorithmState = "SUCCEEDED"
	AlgorithmStateFAILEDHANDLED   AlgorithmState = "FAILED_HANDLED"
	AlgorithmStateFAILEDUNHANDLED AlgorithmState = "FAILED_UNHANDLED"
)

func (*AlgorithmState) Scan

func (e *AlgorithmState) Scan(src interface{}) error

type Annotation

type Annotation struct {
	ID int64
	// Start time of the annotation time window
	TimeFrom pgtype.Timestamp
	// End time of the annotation time window
	TimeTo   pgtype.Timestamp
	Metadata []byte
	// Detailed description of the annotation
	Description pgtype.Text
	CreatedAt   pgtype.Timestamp
}

Plot annotations with time ranges and metadata

type AnnotationAlgorithm

type AnnotationAlgorithm struct {
	AnnotationID int64
	AlgorithmID  int64
}

Junction table linking annotations to algorithms

type AnnotationWindowType

type AnnotationWindowType struct {
	AnnotationID int64
	WindowTypeID int64
}

Junction table linking annotations to window types

type CircularDependencyError

type CircularDependencyError struct {
	FromAlgoName      string
	ToAlgoName        string
	FromAlgoVersion   string
	ToAlgoVersion     string
	FromAlgoProcessor string
	ToAlgoProcessor   string
}

func (*CircularDependencyError) Error

func (c *CircularDependencyError) Error() string

type CreateAlgorithmDependencyParams

type CreateAlgorithmDependencyParams struct {
	LookbackCount        int64
	LookbackTimedelta    int64
	LookbackGapCount     int64
	LookbackGapTimedelta int64
	FromAlgorithmName    string
	FromAlgorithmVersion string
	FromProcessorName    string
	FromProcessorRuntime string
	ToAlgorithmName      string
	ToAlgorithmVersion   string
	ToProcessorName      string
	ToProcessorRuntime   string
}

type CreateAlgorithmParams

type CreateAlgorithmParams struct {
	Name                     string
	Version                  string
	Description              string
	ResultType               ResultType
	SelfLookbackCount        int64
	SelfLookbackTimedelta    int64
	SelfLookbackGapCount     int64
	SelfLookbackGapTimedelta int64
	ProcessorName            string
	ProcessorRuntime         string
	WindowTypeName           string
	WindowTypeVersion        string
}

type CreateMetadataFieldParams

type CreateMetadataFieldParams struct {
	Name        string
	Description string
	Filter      pgtype.Bool
}

type CreateProcessorParams

type CreateProcessorParams struct {
	Name             string
	Runtime          string
	ConnectionString string
	ProjectName      pgtype.Text
}

type CreateResultParams

type CreateResultParams struct {
	WindowsID    pgtype.Int8
	WindowTypeID pgtype.Int8
	AlgorithmID  pgtype.Int8
}

type CreateWindowTypeMetadataFieldBridgeParams

type CreateWindowTypeMetadataFieldBridgeParams struct {
	WindowTypeID     int64
	MetadataFieldsID int64
}

type CreateWindowTypeParams

type CreateWindowTypeParams struct {
	Name        string
	Version     string
	Description string
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type Datalayer

type Datalayer struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, connStr string) (*Datalayer, error)

generate a new client for the postgres datalayer

func (*Datalayer) EmitWindow

func (d *Datalayer) EmitWindow(
	ctx context.Context,
	window *pb.Window,
	useTls bool,
) (_ pb.WindowEmitStatus, retErr error)

EmitWindow with Orca core

func (*Datalayer) Expose

func (d *Datalayer) Expose(
	ctx context.Context,
	settings *pb.ExposeSettings,
) (_ *pb.InternalState, retErr error)

func (*Datalayer) RegisterProcessor

func (d *Datalayer) RegisterProcessor(
	ctx context.Context,
	proc *pb.ProcessorRegistration,
) (retErr error)

RegisterProcessor with Orca Core

type FinaliseResultParams

type FinaliseResultParams struct {
	ResultValue pgtype.Float8
	ResultArray []float64
	ResultJson  []byte
	State       AlgorithmState
	Err         []byte
	ResultID    int64
}

type Metadata

type Metadata struct {
	WindowsID     int64
	WindowTypeID  int64
	MetadataKey   string
	MetadataValue pgtype.Float8
	MetadataArray []float64
	MetadataJson  []byte
}

type MetadataField

type MetadataField struct {
	ID          int64
	Name        string
	Description string
	Filter      pgtype.Bool
}

type MetadataFieldsReference

type MetadataFieldsReference struct {
	WindowTypeID     int64
	MetadataFieldsID int64
}

type MetadataFilter

type MetadataFilter struct {
	Key   string `json:"key"`
	Value any    `json:"value"`
}

converts a structpb struct to a form that can be used to filter metadata in the db

type NullAlgorithmState

type NullAlgorithmState struct {
	AlgorithmState AlgorithmState
	Valid          bool // Valid is true if AlgorithmState is not NULL
}

func (*NullAlgorithmState) Scan

func (ns *NullAlgorithmState) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAlgorithmState) Value

func (ns NullAlgorithmState) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullResultType

type NullResultType struct {
	ResultType ResultType
	Valid      bool // Valid is true if ResultType is not NULL
}

func (*NullResultType) Scan

func (ns *NullResultType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullResultType) Value

func (ns NullResultType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullWindowState

type NullWindowState struct {
	WindowState WindowState
	Valid       bool // Valid is true if WindowState is not NULL
}

func (*NullWindowState) Scan

func (ns *NullWindowState) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullWindowState) Value

func (ns NullWindowState) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type PgTx

type PgTx struct {
	// contains filtered or unexported fields
}

func (*PgTx) Commit

func (t *PgTx) Commit(ctx context.Context) error

func (*PgTx) Rollback

func (t *PgTx) Rollback(ctx context.Context)

type Processor

type Processor struct {
	ID               int64
	Name             string
	Runtime          string
	ConnectionString string
	Created          pgtype.Timestamp
	ProjectName      pgtype.Text
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateAlgorithm

func (q *Queries) CreateAlgorithm(ctx context.Context, arg CreateAlgorithmParams) error

func (*Queries) CreateAlgorithmDependency

func (q *Queries) CreateAlgorithmDependency(ctx context.Context, arg CreateAlgorithmDependencyParams) error

func (*Queries) CreateMetadataField

func (q *Queries) CreateMetadataField(ctx context.Context, arg CreateMetadataFieldParams) (int64, error)

func (*Queries) CreateProcessor

func (q *Queries) CreateProcessor(ctx context.Context, arg CreateProcessorParams) error

func (*Queries) CreateResult

func (q *Queries) CreateResult(ctx context.Context, arg CreateResultParams) (int64, error)

func (*Queries) CreateWindowType

func (q *Queries) CreateWindowType(ctx context.Context, arg CreateWindowTypeParams) (int64, error)

func (*Queries) CreateWindowTypeMetadataFieldBridge

func (q *Queries) CreateWindowTypeMetadataFieldBridge(ctx context.Context, arg CreateWindowTypeMetadataFieldBridgeParams) error

func (*Queries) FinaliseResult

func (q *Queries) FinaliseResult(ctx context.Context, arg FinaliseResultParams) error

func (*Queries) ReadAlgorithmExecutionPaths

func (q *Queries) ReadAlgorithmExecutionPaths(ctx context.Context, windowTypeID string) ([]AlgorithmExecutionPath, error)

func (*Queries) ReadAlgorithmExecutionPathsForAlgo

func (q *Queries) ReadAlgorithmExecutionPathsForAlgo(ctx context.Context, algoID int64) ([]AlgorithmExecutionPath, error)

func (*Queries) ReadAlgorithmId

func (q *Queries) ReadAlgorithmId(ctx context.Context, arg ReadAlgorithmIdParams) (int64, error)

func (*Queries) ReadAlgorithms

func (q *Queries) ReadAlgorithms(ctx context.Context) ([]Algorithm, error)

func (*Queries) ReadAlgorithmsForProcessorId

func (q *Queries) ReadAlgorithmsForProcessorId(ctx context.Context, processorID int64) ([]Algorithm, error)

func (*Queries) ReadAlgorithmsForWindow

func (q *Queries) ReadAlgorithmsForWindow(ctx context.Context, arg ReadAlgorithmsForWindowParams) ([]Algorithm, error)

func (*Queries) ReadFromAlgorithmDependencies

func (q *Queries) ReadFromAlgorithmDependencies(ctx context.Context, arg ReadFromAlgorithmDependenciesParams) ([]AlgorithmDependency, error)

func (*Queries) ReadMetadataFields

func (q *Queries) ReadMetadataFields(ctx context.Context) ([]MetadataField, error)

func (*Queries) ReadMetadataFieldsByWindowType

func (q *Queries) ReadMetadataFieldsByWindowType(ctx context.Context, windowTypeID int64) ([]MetadataField, error)

func (*Queries) ReadProcessorExcludeProject

func (q *Queries) ReadProcessorExcludeProject(ctx context.Context, projectName pgtype.Text) ([]Processor, error)

func (*Queries) ReadProcessors

func (q *Queries) ReadProcessors(ctx context.Context) ([]Processor, error)

func (*Queries) ReadProcessorsByIDs

func (q *Queries) ReadProcessorsByIDs(ctx context.Context, processorIds []int64) ([]Processor, error)

func (*Queries) ReadWindowTypeMetadataFields

func (q *Queries) ReadWindowTypeMetadataFields(ctx context.Context) ([]WindowTypeMetadataField, error)

func (*Queries) ReadWindowTypes

func (q *Queries) ReadWindowTypes(ctx context.Context) ([]WindowType, error)

func (*Queries) ReadWindowTypesByName

func (q *Queries) ReadWindowTypesByName(ctx context.Context, arg ReadWindowTypesByNameParams) ([]WindowType, error)

func (*Queries) RegisterMetadata

func (q *Queries) RegisterMetadata(ctx context.Context, arg RegisterMetadataParams) error

func (*Queries) RegisterWindow

func (q *Queries) RegisterWindow(ctx context.Context, arg RegisterWindowParams) (RegisterWindowRow, error)

func (*Queries) UpdateResultState

func (q *Queries) UpdateResultState(ctx context.Context, arg UpdateResultStateParams) error

func (*Queries) UpdateWindowState

func (q *Queries) UpdateWindowState(ctx context.Context, arg UpdateWindowStateParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ReadAlgorithmIdParams

type ReadAlgorithmIdParams struct {
	AlgorithmName    string
	AlgorithmVersion string
	ProcessorName    string
	ProcessorRuntime string
}

type ReadAlgorithmsForWindowParams

type ReadAlgorithmsForWindowParams struct {
	WindowTypeName    string
	WindowTypeVersion string
}

type ReadFromAlgorithmDependenciesParams

type ReadFromAlgorithmDependenciesParams struct {
	FromAlgorithmName    string
	FromAlgorithmVersion string
	FromProcessorName    string
	FromProcessorRuntime string
}

type ReadResultsForAlgorithmByCountParams

type ReadResultsForAlgorithmByCountParams struct {
	AlgorithmID     pgtype.Int8
	SearchTo        pgtype.Timestamp
	MetadataFilters []byte
	CountOffset     int32
	Limit           pgtype.Int4
}

type ReadResultsForAlgorithmByCountRow

type ReadResultsForAlgorithmByCountRow struct {
	ResultID          int64
	AlgorithmID       pgtype.Int8
	WindowID          int64
	ResultType        ResultType
	ResultValue       pgtype.Float8
	ResultArray       []float64
	ResultJson        []byte
	WindowTypeName    string
	WindowTypeVersion string
	WindowTimeFrom    pgtype.Timestamp
	WindowTimeTo      pgtype.Timestamp
	WindowOrigin      string
	WindowMetadata    []byte
}

type ReadResultsForAlgorithmByTimedeltaParams

type ReadResultsForAlgorithmByTimedeltaParams struct {
	AlgorithmID     pgtype.Int8
	SearchFrom      pgtype.Timestamp
	SearchTo        pgtype.Timestamp
	MetadataFilters []byte
	CountOffset     int32
	Limit           pgtype.Int4
}

type ReadResultsForAlgorithmByTimedeltaRow

type ReadResultsForAlgorithmByTimedeltaRow struct {
	ResultID          int64
	AlgorithmID       pgtype.Int8
	WindowID          int64
	ResultType        ResultType
	ResultValue       pgtype.Float8
	ResultArray       []float64
	ResultJson        []byte
	WindowTypeName    string
	WindowTypeVersion string
	WindowTimeFrom    pgtype.Timestamp
	WindowTimeTo      pgtype.Timestamp
	WindowOrigin      string
	WindowMetadata    []byte
}

type ReadWindowTypesByNameParams

type ReadWindowTypesByNameParams struct {
	Name    string
	Version string
}

type RegisterMetadataParams

type RegisterMetadataParams struct {
	WindowsID     int64
	WindowTypeID  int64
	MetadataKey   string
	MetadataValue pgtype.Float8
	MetadataArray []float64
	MetadataJson  []byte
}

type RegisterWindowParams

type RegisterWindowParams struct {
	TimeFrom          pgtype.Timestamp
	TimeTo            pgtype.Timestamp
	Origin            string
	WindowTypeName    string
	WindowTypeVersion string
}

type RegisterWindowRow

type RegisterWindowRow struct {
	WindowTypeID int64
	ID           int64
}

type Result

type Result struct {
	ID           int64
	WindowsID    pgtype.Int8
	WindowTypeID pgtype.Int8
	AlgorithmID  pgtype.Int8
	ResultValue  pgtype.Float8
	ResultArray  []float64
	ResultJson   []byte
	State        AlgorithmState
	Error        []byte
}

type ResultType

type ResultType string
const (
	ResultTypeStruct ResultType = "struct"
	ResultTypeArray  ResultType = "array"
	ResultTypeValue  ResultType = "value"
	ResultTypeNone   ResultType = "none"
)

func (*ResultType) Scan

func (e *ResultType) Scan(src interface{}) error

type UpdateResultStateParams

type UpdateResultStateParams struct {
	State    AlgorithmState
	ResultID int64
}

type UpdateWindowStateParams

type UpdateWindowStateParams struct {
	State    WindowState
	WindowID int64
}

type Window

type Window struct {
	ID           int64
	WindowTypeID int64
	TimeFrom     pgtype.Timestamp
	TimeTo       pgtype.Timestamp
	Origin       string
	Created      pgtype.Timestamp
	State        WindowState
}

type WindowState

type WindowState string
const (
	WindowStatePENDING            WindowState = "PENDING"
	WindowStateFAILED             WindowState = "FAILED"
	WindowStatePROCESSING         WindowState = "PROCESSING"
	WindowStatePROCESSINGFINISHED WindowState = "PROCESSING_FINISHED"
)

func (*WindowState) Scan

func (e *WindowState) Scan(src interface{}) error

type WindowType

type WindowType struct {
	ID          int64
	Name        string
	Version     string
	Description string
	Created     pgtype.Timestamp
}

type WindowTypeMetadataField

type WindowTypeMetadataField struct {
	WindowTypeName           string
	WindowTypeVersion        string
	MetadataFieldID          int64
	MetadataFieldName        string
	MetadataFieldDescription string
}

Jump to

Keyboard shortcuts

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