connparams

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// No SSL.
	SSLModeDisable = "disable"

	// Always SSL (skip verification).
	SSLModeRequire = "require"

	// Always SSL (verify that the certificate presented by the server was
	// signed by a trusted CA)
	SSLModeVerifyCA = "verify-ca"

	// Always SSL (verify that the certification presented by the server
	// was signed by a trusted CA and the server host name matches the one
	// in the certificate)
	SSLModeVerifyFull = "verify-full"
)

The possible SSL modes.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionParams

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

func New

func New(dbName string, opts ...Option) ConnectionParams

New constructs a new ConnectionParams for the specified dbName.

func NewWithDefaults

func NewWithDefaults(dbName string, opts ...Option) ConnectionParams

NewWithDefaults returns a ConnectionParams for the specified dbName with default params set.

func (ConnectionParams) DBName

func (p ConnectionParams) DBName() string

func (ConnectionParams) Equal added in v0.2.0

func (p ConnectionParams) Equal(other ConnectionParams) bool

func (ConnectionParams) KeyValues added in v0.2.0

func (p ConnectionParams) KeyValues() KeyValues

func (ConnectionParams) String added in v0.2.0

func (p ConnectionParams) String() string

String returns a string representation of the connection params. Although this can be used as a connection string, it's main purpose is debugging and testing. Either 'p.URI().String()' or 'p.KeyValues().String()' should be used to construct the connection string.

func (ConnectionParams) URI

func (p ConnectionParams) URI() *url.URL

type Factory

type Factory func(dbName string, opts ...Option) ConnectionParams

func DefaultFactory

func DefaultFactory() Factory

type KeyValue added in v0.2.0

type KeyValue struct {
	Key   string
	Value string
}

func (KeyValue) String added in v0.2.0

func (kv KeyValue) String() string

type KeyValues added in v0.2.0

type KeyValues []KeyValue

func (KeyValues) String added in v0.2.0

func (kvs KeyValues) String() string

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is a parameter to configure the connection.

func WithConnectionTimeout

func WithConnectionTimeout(connectionTimeout int) Option

WithConnectionTimeout returns a Option specifying maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.

func WithFallbackApplicationName

func WithFallbackApplicationName(fallbackApplicationName string) Option

WithFallbackApplicationName returns a Option specifying an application_name to fall back to if one isn't provided.

func WithHost

func WithHost(host string) Option

WithHost returns a Option specifying Are for unix domain sockets.

func WithPassword

func WithPassword(password string) Option

WithPassword returns a Option specifying the user's password.

func WithPort

func WithPort(port int) Option

WithPort returns a Option specifying the port to bind to.

func WithSSLCert

func WithSSLCert(sslCert string) Option

WithSSLCert returns a Option specifying cert file location. The file must contain PEM encoded data.

func WithSSLKey

func WithSSLKey(sslKey string) Option

WithSSLKey returns a Option specifying key file location. The file must contain PEM encoded data.

func WithSSLMode

func WithSSLMode(sslMode string) Option

WithSSLMode returns a Option specifying whether or not to use SSL.

func WithSSLRootCert

func WithSSLRootCert(sslRootCert string) Option

WithSSLRootCert returns a Option specifying the location of the root certificate file. The file must contain PEM encoded data

func WithService

func WithService(service string) Option

WithService returns a Option specifying gSS (Kerberos) service name to use when constructing the SPN.

func WithUser

func WithUser(user string) Option

WithUser returns a Option specifying the name of the database to connect to.

Jump to

Keyboard shortcuts

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