connections

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserEnvVar = "INFLUX_USERNAME"
	PassEnvVar = "INFLUX_PASSWORD"
)

Environment variable names to be used for the InfluxDB connection

Variables

This section is empty.

Functions

This section is empty.

Types

type InfluxConnectionParams

type InfluxConnectionParams struct {
	Server      string
	Username    string
	Password    string
	Database    string
	UnsafeHTTPS bool
}

InfluxConnectionParams represents the parameters required to open a InfluxDB connection

type InfluxConnectionService

type InfluxConnectionService interface {
	NewConnection(*InfluxConnectionParams) (influx.Client, error)
}

InfluxConnectionService creates new clients connected to some Influx server

func NewInfluxConnectionService

func NewInfluxConnectionService() InfluxConnectionService

NewInfluxConnectionService creates a new instance of the service

type MockPgxW

type MockPgxW struct {
	ExecRes         []pgx.CommandTag
	ExecErrs        []error
	CurrentExec     int
	QueryRes        []*pgx.Rows
	QueryErrs       []error
	CurrentQ        int
	ExpQ            []string
	ExpQArgs        [][]interface{}
	ExpExec         []string
	ExpExecArgs     [][]interface{}
	BeginRes        []*pgx.Tx
	BeginErr        []error
	CurrentBegin    int
	CopyFromErr     []error
	CurrentCopyFrom int
	ExpCopyFromTab  []pgx.Identifier
	ExpCopyFromCol  [][]string
}

MockPgxW is a mock implementation of the PgxWrapper.

func (*MockPgxW) Begin

func (t *MockPgxW) Begin() (*pgx.Tx, error)

Begin opens a transaction.

func (*MockPgxW) Close

func (t *MockPgxW) Close() error

Close the connection.

func (*MockPgxW) CopyFrom

func (t *MockPgxW) CopyFrom(tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int, error)

CopyFrom uses COPY to insert data.

func (*MockPgxW) Exec

func (t *MockPgxW) Exec(sql string, arguments ...interface{}) (commandTag pgx.CommandTag, err error)

Exec executes an SQL statement, no results returned.

func (*MockPgxW) Query

func (t *MockPgxW) Query(sql string, args ...interface{}) (*pgx.Rows, error)

Query data from the db.

type PgxWrap

type PgxWrap interface {
	Begin() (*pgx.Tx, error)
	CopyFrom(tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int, error)
	Exec(sql string, arguments ...interface{}) (commandTag pgx.CommandTag, err error)
	Query(sql string, args ...interface{}) (*pgx.Rows, error)
	Close() error
}

PgxWrap represents a wrapper interface around pgx.Conn, for easier testing.

func NewPgxWrapper

func NewPgxWrapper(db *pgx.Conn) PgxWrap

NewPgxWrapper creates a new pgx.Conn wrapper.

type TSConnectionService

type TSConnectionService interface {
	NewConnection(connectionString string) (PgxWrap, error)
}

TSConnectionService creates new timescale db connections

func NewTSConnectionService

func NewTSConnectionService() TSConnectionService

NewTSConnectionService creates a new TSConnectionService instance

Jump to

Keyboard shortcuts

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