plugin

package
v0.0.0-...-bbc6343 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MinSupportedPGVersion = 100000
)
View Source
const (
	Name = "PostgreSQL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnManager

type ConnManager struct {
	sync.Mutex

	Destroy context.CancelFunc
	// contains filtered or unexported fields
}

ConnManager is a thread-safe structure for manage connections.

func NewConnManager

func NewConnManager(keepAlive, connectTimeout, callTimeout,
	hkInterval time.Duration, queryStorage yarn.Yarn) *ConnManager

NewConnManager initializes connManager structure and runs Go Routine that watches for unused connections.

func (*ConnManager) GetConnection

func (c *ConnManager) GetConnection(ci connID, params map[string]string) (conn *PGConn, err error)

GetConnection returns an existing connection or creates a new one.

type PGConn

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

PGConn holds pointer to the Pool of PostgreSQL Instance.

func (*PGConn) PostgresVersion

func (conn *PGConn) PostgresVersion() int

PostgresVersion returns the version of PostgreSQL server we are currently connected to.

func (*PGConn) Query

func (conn *PGConn) Query(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error)

Query wraps pgxpool.Query.

func (*PGConn) QueryByName

func (conn *PGConn) QueryByName(ctx context.Context, queryName string, args ...interface{}) (rows *sql.Rows, err error)

QueryByName executes a query from queryStorage by its name and returns a single row.

func (*PGConn) QueryRow

func (conn *PGConn) QueryRow(ctx context.Context, query string, args ...interface{}) (row *sql.Row, err error)

QueryRow wraps pgxpool.QueryRow.

func (*PGConn) QueryRowByName

func (conn *PGConn) QueryRowByName(ctx context.Context, queryName string, args ...interface{}) (row *sql.Row, err error)

QueryRowByName executes a query from queryStorage by its name and returns a single row.

type Plugin

type Plugin struct {
	plugin.Base
	// contains filtered or unexported fields
}

Plugin inherits plugin.Base and store plugin-specific data.

var Impl Plugin

Impl is the pointer to the plugin implementation.

func (*Plugin) Configure

func (p *Plugin) Configure(global *plugin.GlobalOptions, options interface{})

Configure implements the Configurator interface. Initializes configuration structures.

func (*Plugin) Export

func (p *Plugin) Export(key string, rawParams []string, _ plugin.ContextProvider) (result any, err error)

Export implements the Exporter interface.

func (*Plugin) Start

func (p *Plugin) Start()

Start implements the Runner interface and performs initialization when plugin is activated.

func (*Plugin) Stop

func (p *Plugin) Stop()

Stop implements the Runner interface and frees resources when plugin is deactivated.

func (*Plugin) Validate

func (p *Plugin) Validate(options interface{}) error

Validate implements the Configurator interface. Returns an error if validation of a plugin's configuration is failed.

type PluginOptions

type PluginOptions struct {
	plugin.SystemOptions `conf:"optional,name=System"`

	// Timeout is the maximum time in seconds for waiting when a connection has to be established.
	// Default value equals to the global agent timeout.
	Timeout int `conf:"optional,range=1:30"`

	// CallTimeout is the maximum time in seconds for waiting when a request has to be done.
	// Default value equals to the global agent timeout.
	CallTimeout int `conf:"optional,range=1:30"`

	// KeepAlive is a time to wait before unused connections will be closed.
	KeepAlive int `conf:"optional,range=60:900,default=300"`

	// Sessions stores pre-defined named sets of connections settings.
	Sessions map[string]Session `conf:"optional"`

	// CustomQueriesPath is a full pathname of a directory containing *.sql files with custom queries.
	CustomQueriesPath string `conf:"optional"`

	// Default stores default connection parameter values from configuration file
	Default Session `conf:"optional"`
}

PluginOptions are options for PostgreSQL connection.

type PostgresClient

type PostgresClient interface {
	Query(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error)
	QueryByName(ctx context.Context, queryName string, args ...interface{}) (rows *sql.Rows, err error)
	QueryRow(ctx context.Context, query string, args ...interface{}) (row *sql.Row, err error)
	QueryRowByName(ctx context.Context, queryName string, args ...interface{}) (row *sql.Row, err error)
	PostgresVersion() int
}

type PostgresURIValidator

type PostgresURIValidator struct {
	Defaults       *uri.Defaults
	AllowedSchemes []string
}

func (PostgresURIValidator) Validate

func (v PostgresURIValidator) Validate(value *string) error

type Session

type Session struct {
	// URI is a connection string consisting of a network scheme, a host address and a port or a path to a Unix-socket.
	URI string `conf:"name=Uri,optional"`

	// User of PostgreSQL server.
	User string `conf:"optional"`

	// Password to send to protected PostgreSQL server.
	Password string `conf:"optional"`

	// Database of PostgreSQL server.
	Database string `conf:"optional"`

	// Connection type of PostgreSQL server.
	TLSConnect string `conf:"name=TLSConnect,optional"`

	// Certificate Authority filepath for PostgreSQL server.
	TLSCAFile string `conf:"name=TLSCAFile,optional"`

	// Certificate filepath for PostgreSQL server.
	TLSCertFile string `conf:"name=TLSCertFile,optional"`

	// Key filepath for PostgreSQL server.
	TLSKeyFile string `conf:"name=TLSKeyFile,optional"`

	// CacheMode for PostgreSQL server.
	CacheMode string `conf:"name=CacheMode,optional"`
}

Session struct holds individual options for PostgreSQL connection for each session.

Jump to

Keyboard shortcuts

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