database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Sqlserver               = "sqlserver"
	Psql                    = "psql"
	CreateMapKey            = "create"
	DeleteMapKey            = "delete"
	K8sMapKey               = "k8sName"
	UserMapKey              = "username"
	PassMapKey              = "password"
	DbNameMapKey            = "dbName"
	FqdnMapKey              = "fqdn"
	PortMapKey              = "port"
	ErrorOnMissingKeyOption = "missingkey=error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dbms

type Dbms struct {
	Driver     string
	Operations map[string]Operation
	Endpoints  []Endpoint
}

Dbms is the instance associated with a Dbms resource. It contains the Driver responsible for the Operations executed on Endpoints.

func (Dbms) RenderOperation

func (d Dbms) RenderOperation(opKey string, values OpValues) (Operation, error)

RenderOperation renders "actions" specified through the use of the Go text/template format. It renders Dbms.Input of the receiver. Data to be inserted is taken directly from values. See OpValues. If the rendering is successful, the method returns a rendered Operation, if an error is generated, it is returned along with an empty Operation struct. Keys which are specified but not found generate an error (i.e. no unreferenced keys are allowed).

type DbmsConfig

type DbmsConfig []Dbms

DbmsConfig is a slice containing Dbms structs.

func (DbmsConfig) GetByDriverAndEndpoint

func (c DbmsConfig) GetByDriverAndEndpoint(driver, endpoint string) (Dbms, error)

type DbmsConn

type DbmsConn struct {
	Driver
}

DbmsConn represents the DBMS connection. See Driver.

func New

func New(dsn Dsn, ops map[string]Operation) (*DbmsConn, error)

New initializes a Dbms instance based on a map of Operation. It expects a dsn like that: driver://username:password@host/instance?param1=value&param2=value

See the individual Driver implementations.

type Driver

type Driver interface {
	CreateDb(operation Operation) OpOutput
	DeleteDb(operation Operation) OpOutput
	Ping() error
}

Driver represents a struct responsible for executing CreateDb and DeleteDb operations on a system it supports. Drivers should provide a way to check their current status (i.e. whether it can accept CreateDb and DeleteDb operations at the moment of a Ping call

type Dsn

type Dsn string

func NewDsn

func NewDsn(driver, username, password, host, port, dbName string) Dsn

func (Dsn) GetDriver

func (s Dsn) GetDriver() string

func (Dsn) String

func (s Dsn) String() string

func (Dsn) WithTable

func (s Dsn) WithTable(table string) Dsn

WithTable set the table associated with the connection.

type Endpoint

type Endpoint struct {
	Name string
	Dsn  Dsn
}

func (Endpoint) IsDsnPresent

func (e Endpoint) IsDsnPresent() bool

func (Endpoint) IsNamePresent

func (e Endpoint) IsNamePresent() bool

type MssqlConn

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

func NewMssqlConn

func NewMssqlConn(dsn Dsn) (*MssqlConn, error)

func (*MssqlConn) CreateDb

func (c *MssqlConn) CreateDb(operation Operation) OpOutput

func (*MssqlConn) DeleteDb

func (c *MssqlConn) DeleteDb(operation Operation) OpOutput

func (*MssqlConn) Ping

func (c *MssqlConn) Ping() error

type OpOutput

type OpOutput struct {
	Out []string // May be changed to interface{} if typing is needed
	Err error
}

OpOutput represents the return values of an operation. If the operation generates an error, it must be set in the Err field. If Err is nil, the operation is assumed to be successful.

type OpValues

type OpValues struct {
	Metadata   map[string]interface{}
	Parameters map[string]string
}

type Operation

type Operation struct {
	Name    string
	Inputs  map[string]string
	Outputs map[string]string
}

type PsqlConn

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

func NewPsqlConn

func NewPsqlConn(dsn string) (*PsqlConn, error)

func (*PsqlConn) CreateDb

func (c *PsqlConn) CreateDb(operation Operation) OpOutput

func (*PsqlConn) DeleteDb

func (c *PsqlConn) DeleteDb(operation Operation) OpOutput

func (*PsqlConn) Ping

func (c *PsqlConn) Ping() error

Jump to

Keyboard shortcuts

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