plugin

package
v0.0.0-...-0922458 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: AGPL-3.0 Imports: 27 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 {
	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,
) (*PGConn, 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 ...any) (*sql.Rows, error)

Query wraps pgxpool.Query.

func (*PGConn) QueryByName

func (conn *PGConn) QueryByName(ctx context.Context, queryName string, args ...any) (*sql.Rows, 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 ...any) (*sql.Row, error)

QueryRow wraps pgxpool.QueryRow.

func (*PGConn) QueryRowByName

func (conn *PGConn) QueryRowByName(
	ctx context.Context, queryName string, args ...any,
) (*sql.Row, 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 any)

Configure implements the Configurator interface. Initializes configuration structures.

func (*Plugin) Export

func (p *Plugin) Export(key string, rawParams []string, pluginCtx plugin.ContextProvider) (any, 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 (*Plugin) Validate(options any) error

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

type PluginOptions

type PluginOptions struct {
	System plugin.SystemOptions `conf:"optional"` //nolint:staticcheck
	// 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"`

	// CustomQueriesEnabled disabled or enabled custom query functionality.
	CustomQueriesEnabled bool `conf:"optional,default=false"`

	// 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 ...any) (rows *sql.Rows, err error)
	QueryByName(ctx context.Context, queryName string, args ...any) (rows *sql.Rows, err error)
	QueryRow(ctx context.Context, query string, args ...any) (row *sql.Row, err error)
	QueryRowByName(ctx context.Context, queryName string, args ...any) (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.

Source Files

  • config.go
  • config_nix.go
  • conn.go
  • handler_archive.go
  • handler_autovacuum.go
  • handler_bgwriter.go
  • handler_cache.go
  • handler_connections.go
  • handler_custom_query.go
  • handler_database_age.go
  • handler_database_size.go
  • handler_databases_bloating.go
  • handler_databases_discovery.go
  • handler_dbstat.go
  • handler_locks.go
  • handler_oldest_xid.go
  • handler_ping.go
  • handler_queries.go
  • handler_replication.go
  • handler_replication_process_name_discovery.go
  • handler_uptime.go
  • handler_version.go
  • handler_wal.go
  • metrics.go
  • postgresql.go
  • testpool.go

Jump to

Keyboard shortcuts

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