sqldb

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropDatabase

func DropDatabase(trans Transactor) error

DropDatabase drops the database associated with the given Transactor (which embeds a live database connection). This is destructive, you will lose data.

func EnvOr

func EnvOr(envName, defaultVal string) string

func GetTestConfig

func GetTestConfig() *controller.SQLDBConfig

func GetTestConfigRandomDB

func GetTestConfigRandomDB(dbprefix string) *controller.SQLDBConfig

func NewBalancer

func NewBalancer(log logger.Logger) *balancer.Balancer

NewBalancer returns a new instance of controller.Balancer.

func NewDirectiveVersion

func NewDirectiveVersion(log logger.Logger) dax.DirectiveVersion

func NewFreeJobService

func NewFreeJobService(log logger.Logger) balancer.FreeJobService

func NewFreeWorkerService

func NewFreeWorkerService(log logger.Logger) balancer.FreeWorkerService

func NewNodeService

func NewNodeService(log logger.Logger) *nodeService

func NewSchemar

func NewSchemar(log logger.Logger) schemar.Schemar

func NewWorkerJobService

func NewWorkerJobService(log logger.Logger) balancer.WorkerJobService

Types

type DaxTransaction

type DaxTransaction struct {
	C *pop.Connection
}

DaxTransaction is a thin wrapper to create a dax.Transaction from a pop Transaction/Connection.

func (*DaxTransaction) Commit

func (w *DaxTransaction) Commit() error

func (*DaxTransaction) Context

func (w *DaxTransaction) Context() context.Context

func (*DaxTransaction) Rollback

func (w *DaxTransaction) Rollback() error

type EmbedMigrator

type EmbedMigrator struct {
	pop.Migrator
	FS fs.FS
	// contains filtered or unexported fields
}

EmbedMigrator is a migrator for SQL and Fizz files which are embedded in any fs.FS. This is lifted directly from pop's FileMigrator and tweaked slightly to take an fs.FS instead of a file path.

func NewEmbedMigrator

func NewEmbedMigrator(fs fs.FS, c *pop.Connection, log logger.Logger) (*EmbedMigrator, error)

NewEmbedMigrator for a path and a Connection

type Schemar

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

Schemar is the SQL implementation of the schemar that stores all the information in a SQL database.

func (*Schemar) CreateDatabase

func (s *Schemar) CreateDatabase(tx dax.Transaction, qdb *dax.QualifiedDatabase) error

func (*Schemar) CreateField

func (s *Schemar) CreateField(tx dax.Transaction, qtid dax.QualifiedTableID, field *dax.Field) error

func (*Schemar) CreateTable

func (s *Schemar) CreateTable(tx dax.Transaction, qtbl *dax.QualifiedTable) error

func (*Schemar) DatabaseByID

func (*Schemar) DatabaseByName

func (s *Schemar) DatabaseByName(tx dax.Transaction, orgID dax.OrganizationID, dbname dax.DatabaseName) (*dax.QualifiedDatabase, error)

func (*Schemar) Databases

func (s *Schemar) Databases(tx dax.Transaction, orgID dax.OrganizationID, dbIDs ...dax.DatabaseID) ([]*dax.QualifiedDatabase, error)

Databases returns a list of databases. If the list of DatabaseIDs is empty, all databases will be returned. If greater than zero DatabaseIDs are passed in the second argument, only databases matching those IDs will be returned.

func (*Schemar) DropDatabase

func (s *Schemar) DropDatabase(tx dax.Transaction, qdb dax.QualifiedDatabaseID) error

func (*Schemar) DropField

func (s *Schemar) DropField(tx dax.Transaction, qtid dax.QualifiedTableID, fieldName dax.FieldName) error

func (*Schemar) DropTable

func (s *Schemar) DropTable(tx dax.Transaction, qtid dax.QualifiedTableID) error

func (*Schemar) SetDatabaseOption

func (s *Schemar) SetDatabaseOption(tx dax.Transaction, qdbid dax.QualifiedDatabaseID, option string, value string) error

func (*Schemar) Table

func (*Schemar) TableID

func (s *Schemar) TableID(tx dax.Transaction, qdbid dax.QualifiedDatabaseID, tableName dax.TableName) (dax.QualifiedTableID, error)

TableID is a reverse-lookup method to get the TableID for a given qualified TableName.

func (*Schemar) Tables

func (s *Schemar) Tables(tx dax.Transaction, qdbid dax.QualifiedDatabaseID, tableIDs ...dax.TableID) ([]*dax.QualifiedTable, error)

Tables returns a list of tables in the given database. If tableIDs are given, only tables with matching IDs are returned.

type Transactor

type Transactor struct {
	*pop.Connection
	// contains filtered or unexported fields
}

Transactor wraps a pop Connection to make it into a dax.Transactor which can be used by the controller agnostic of implementation.

func NewTransactor

func NewTransactor(cfg *controller.SQLDBConfig, log logger.Logger) (Transactor, error)

func (Transactor) BeginTx

func (t Transactor) BeginTx(ctx context.Context, writable bool) (dax.Transaction, error)

func (Transactor) Close

func (t Transactor) Close() error

func (Transactor) Start

func (t Transactor) Start() error

Start creates the database specified in the database connection, then runs any outstanding migrations.

Jump to

Keyboard shortcuts

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