dbal

package
v0.0.0-...-b9c5443 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const PgSortAsc = "ASC"
View Source
const PgSortDesc = "DESC"

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	WaitForNotification(ctx context.Context) (*pgconn.Notification, error)
}

Conn is the database connection used by the DBAL.

type DBAL

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

DBAL is the Database Abstraction Layer around asset storage

func New

func New(ctx context.Context, tx pgx.Tx, conn Conn, channel string) *DBAL

func (*DBAL) AddComputePlan

func (d *DBAL) AddComputePlan(plan *asset.ComputePlan) error

AddComputePlan stores a new ComputePlan in DB

func (*DBAL) AddComputeTaskOutputAsset

func (d *DBAL) AddComputeTaskOutputAsset(output *asset.ComputeTaskOutputAsset) error

func (*DBAL) AddComputeTasks

func (d *DBAL) AddComputeTasks(tasks ...*asset.ComputeTask) error

AddComputeTasks add one or multiple tasks to storage.

func (*DBAL) AddDataManager

func (d *DBAL) AddDataManager(datamanager *asset.DataManager) error

AddDataManager implements persistence.DataManagerDBAL

func (*DBAL) AddDataSamples

func (d *DBAL) AddDataSamples(datasamples ...*asset.DataSample) error

AddDataSamples add one or multiple data samples to storage.

func (*DBAL) AddEvents

func (d *DBAL) AddEvents(events ...*asset.Event) error

AddEvents insert events in storage in batch mode.

func (*DBAL) AddFailureReport

func (d *DBAL) AddFailureReport(failureReport *asset.FailureReport) error

func (*DBAL) AddFunction

func (d *DBAL) AddFunction(function *asset.Function) error

AddFunction implements persistence.FunctionDBAL

func (*DBAL) AddModel

func (d *DBAL) AddModel(model *asset.Model, identifier string) error

func (*DBAL) AddOrganization

func (d *DBAL) AddOrganization(organization *asset.Organization) error

AddOrganization implements persistence.OrganizationDBAL

func (*DBAL) AddPerformance

func (d *DBAL) AddPerformance(perf *asset.Performance, identifier string) error

func (*DBAL) AddressableExists

func (d *DBAL) AddressableExists(storageAddress string) (bool, error)

func (*DBAL) CancelComputePlan

func (d *DBAL) CancelComputePlan(plan *asset.ComputePlan, cancelationDate time.Time) error

func (*DBAL) ComputePlanExists

func (d *DBAL) ComputePlanExists(key string) (bool, error)

ComputePlanExists returns true if a ComputePlan with the given key already exists

func (*DBAL) CountComputeTaskRegisteredOutputs

func (d *DBAL) CountComputeTaskRegisteredOutputs(key string) (persistence.ComputeTaskOutputCounter, error)

func (*DBAL) DataManagerExists

func (d *DBAL) DataManagerExists(key string) (bool, error)

DataManagerExists implements persistence.DataManagerDBAL

func (*DBAL) DataSampleExists

func (d *DBAL) DataSampleExists(key string) (bool, error)

DataSampleExists implements persistence.DataSampleDBAL

func (*DBAL) FailComputePlan

func (d *DBAL) FailComputePlan(plan *asset.ComputePlan, failureDate time.Time) error

func (*DBAL) FunctionExists

func (d *DBAL) FunctionExists(key string) (bool, error)

FunctionExists implements persistence.FunctionDBAL

func (*DBAL) GetAllOrganizations

func (d *DBAL) GetAllOrganizations() ([]*asset.Organization, error)

GetAllOrganizations implements persistence.OrganizationDBAL

func (*DBAL) GetComputePlan

func (d *DBAL) GetComputePlan(key string) (*asset.ComputePlan, error)

GetComputePlan fetches a given compute plan

func (*DBAL) GetComputePlanTasks

func (d *DBAL) GetComputePlanTasks(key string) ([]*asset.ComputeTask, error)

GetComputePlanTasks returns the tasks of the compute plan identified by the given key

func (*DBAL) GetComputePlanTasksKeys

func (d *DBAL) GetComputePlanTasksKeys(key string) ([]string, error)

GetComputePlanTasksKeys returns the list of task keys from the provided compute plan

func (*DBAL) GetComputeTask

func (d *DBAL) GetComputeTask(key string) (*asset.ComputeTask, error)

GetComputeTask returns a single task by its key

func (*DBAL) GetComputeTaskChildren

func (d *DBAL) GetComputeTaskChildren(key string) ([]*asset.ComputeTask, error)

GetComputeTaskChildren returns the children of the task identified by the given key. Warning: this function doesn't populate the task input/output fields, not the function input/output fields.

func (*DBAL) GetComputeTaskOutputAssets

func (d *DBAL) GetComputeTaskOutputAssets(taskKey, identifier string) ([]*asset.ComputeTaskOutputAsset, error)

func (*DBAL) GetComputeTaskOutputModels

func (d *DBAL) GetComputeTaskOutputModels(key string) ([]*asset.Model, error)

func (*DBAL) GetComputeTaskParents

func (d *DBAL) GetComputeTaskParents(key string) ([]*asset.ComputeTask, error)

func (*DBAL) GetComputeTasks

func (d *DBAL) GetComputeTasks(keys []string) ([]*asset.ComputeTask, error)

GetComputeTasks returns the list of unique compute tasks identified by the provided keys. It should not be used where pagination is expected!

func (*DBAL) GetDataManager

func (d *DBAL) GetDataManager(key string) (*asset.DataManager, error)

GetDataManager implements persistence.DataManagerDBAL

func (*DBAL) GetDataSample

func (d *DBAL) GetDataSample(key string) (*asset.DataSample, error)

GetDataSample implements persistence.DataSample

func (*DBAL) GetDataSampleKeysByManager

func (d *DBAL) GetDataSampleKeysByManager(dataManagerKey string) ([]string, error)

GetDataSampleKeysByManager returns sample keys linked to a given manager.

func (*DBAL) GetExistingComputeTaskKeys

func (d *DBAL) GetExistingComputeTaskKeys(keys []string) ([]string, error)

GetExistingComputeTaskKeys returns the keys of tasks already in storage among those given as input.

func (*DBAL) GetFailureReport

func (d *DBAL) GetFailureReport(assetKey string) (*asset.FailureReport, error)

func (*DBAL) GetFunction

func (d *DBAL) GetFunction(key string) (*asset.Function, error)

GetFunction implements persistence.FunctionDBAL

func (*DBAL) GetFunctionFromTasksWithStatus

func (d *DBAL) GetFunctionFromTasksWithStatus(key string, statuses []asset.ComputeTaskStatus) ([]*asset.ComputeTask, error)

GetFunctionFromTasksWithStatus returns the list of tasks linked with a function

func (*DBAL) GetModel

func (d *DBAL) GetModel(key string) (*asset.Model, error)

func (*DBAL) GetOrganization

func (d *DBAL) GetOrganization(id string) (*asset.Organization, error)

GetOrganization implements persistence.OrganizationDBAL

func (*DBAL) IsPlanRunning

func (d *DBAL) IsPlanRunning(key string) (bool, error)

func (*DBAL) ModelExists

func (d *DBAL) ModelExists(key string) (bool, error)

func (*DBAL) NewEventID

func (d *DBAL) NewEventID() string

func (*DBAL) OrganizationExists

func (d *DBAL) OrganizationExists(id string) (bool, error)

OrganizationExists implements persistence.OrganizationDBAL

func (*DBAL) PerformanceExists

func (d *DBAL) PerformanceExists(perf *asset.Performance) (bool, error)

PerformanceExists implements persistence.PerformanceDBAL

func (*DBAL) QueryComputePlans

func (d *DBAL) QueryComputePlans(p *common.Pagination, filter *asset.PlanQueryFilter) ([]*asset.ComputePlan, common.PaginationToken, error)

func (*DBAL) QueryComputeTasks

func (d *DBAL) QueryComputeTasks(pagination *common.Pagination, filter *asset.TaskQueryFilter) ([]*asset.ComputeTask, common.PaginationToken, error)

QueryComputeTasks returns a paginated and filtered list of tasks.

func (*DBAL) QueryDataManagers

func (d *DBAL) QueryDataManagers(p *common.Pagination) ([]*asset.DataManager, common.PaginationToken, error)

QueryDataManagers implements persistence.DataManagerDBAL

func (*DBAL) QueryDataSamples

func (d *DBAL) QueryDataSamples(p *common.Pagination, filter *asset.DataSampleQueryFilter) ([]*asset.DataSample, common.PaginationToken, error)

QueryDataSamples implements persistence.DataSample

func (*DBAL) QueryEvents

func (d *DBAL) QueryEvents(p *common.Pagination, filter *asset.EventQueryFilter, sortOrder asset.SortOrder) ([]*asset.Event, common.PaginationToken, error)

func (*DBAL) QueryFunctions

func (d *DBAL) QueryFunctions(p *common.Pagination, filter *asset.FunctionQueryFilter) ([]*asset.Function, common.PaginationToken, error)

QueryFunctions implements persistence.FunctionDBAL

func (*DBAL) QueryPerformances

func (*DBAL) SetComputePlanName

func (d *DBAL) SetComputePlanName(plan *asset.ComputePlan, name string) error

func (*DBAL) SubscribeToEvents

func (d *DBAL) SubscribeToEvents(startEventID string, stream asset.EventService_SubscribeToEventsServer) error

SubscribeToEvents replays already existing events starting from startEventID (excluded), then it waits and forward newly created events.

func (*DBAL) UpdateComputeTaskStatus

func (d *DBAL) UpdateComputeTaskStatus(taskKey string, taskStatus asset.ComputeTaskStatus) error

UpdateComputeTaskStatus updates the status of an existing task.

func (*DBAL) UpdateDataManager

func (d *DBAL) UpdateDataManager(datamanager *asset.DataManager) error

UpdateDataManager updates the mutable fields of a data manager in the DB. List of mutable fields: name.

func (*DBAL) UpdateDataSample

func (d *DBAL) UpdateDataSample(dataSample *asset.DataSample) error

UpdateDataSample implements persistence.DataSampleDBAL

func (*DBAL) UpdateFunction

func (d *DBAL) UpdateFunction(function *asset.Function) error

UpdateFunction updates the mutable fields of a function in the DB. List of mutable fields: name, status, image.

func (*DBAL) UpdateModel

func (d *DBAL) UpdateModel(model *asset.Model) error

type Database

type Database struct {
	Pool PgPool
}

Database is a thin wrapper around PgPool. It handles the orchestrator specifics, such as DBAL creation.

func InitDatabase

func InitDatabase(databaseURL string) (*Database, error)

InitDatabase opens a database connexion from given url.

func (*Database) BeginTransaction

func (d *Database) BeginTransaction(ctx context.Context, readOnly bool) (pgx.Tx, error)

BeginTransaction returns a new transaction. When readOnly is false the transaction is configured with SERIALIZABLE isolation level to protect against potential inconsistencies with concurrent requests.

func (*Database) Close

func (d *Database) Close()

Close the connexion

type PgPool

type PgPool interface {
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
	Close()
}

type SQLLogger

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

func (*SQLLogger) Log

func (l *SQLLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]interface{})

Jump to

Keyboard shortcuts

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