Version: v0.35.0 Latest Latest

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0, BSD-3-Clause, MIT, + 1 more Imports: 12 Imported by: 8


For connection string formats, see ../doc/connection.md.





View Source
const (
	// DefaultPoolMinSessions specifies the default value for minSessions for pool creation.
	DefaultPoolMinSessions = 1
	// DefaultPoolMaxSessions specifies the default value for maxSessions for pool creation.
	DefaultPoolMaxSessions = 1000
	// DefaultSessionIncrement specifies the default value for increment for pool creation.
	DefaultSessionIncrement = 1
	// DefaultPoolIncrement is a deprecated name for DefaultSessionIncrement.
	DefaultPoolIncrement = DefaultSessionIncrement
	// DefaultConnectionClass is empty, which allows to use the poolMinSessions created as part of session pool creation for non-DRCP. For DRCP, connectionClass needs to be explicitly mentioned.
	DefaultConnectionClass = ""
	// NoConnectionPoolingConnectionClass is a special connection class name to indicate no connection pooling.
	// It is the same as setting standaloneConnection=1
	NoConnectionPoolingConnectionClass = "NO-CONNECTION-POOLING"
	// DefaultSessionTimeout is the seconds before idle pool sessions get evicted
	DefaultSessionTimeout = 5 * time.Minute
	// DefaultWaitTimeout is the milliseconds to wait for a session to become available
	DefaultWaitTimeout = 30 * time.Second
	// DefaultMaxLifeTime is the maximum time in seconds till a pooled session may exist
	DefaultMaxLifeTime = 1 * time.Hour
	//DefaultStandaloneConnection holds the default for standaloneConnection.
	DefaultStandaloneConnection = false


View Source
var ErrCannotMarshal = errors.New("cannot be marshaled")


func AppendLogfmt

func AppendLogfmt(w io.Writer, key, value interface{}) error

AppendLogfmt appends the key=val logfmt-formatted.

var buf strings.Builder
AppendLogfmt(&buf, "user", "scott")
AppendLogfmt(&buf, "password", "tiger")
AppendLogfmt(&buf, "connectString", "dbhost:1521/orclpdb1?connect_timeout=2")


func Fuzz

func Fuzz(data []byte) int

See https://github.com/dvyukov/go-fuzz

(cd /tmp && go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build) PATH=$HOME/sdk/go1.14.6/bin:$PATH GO111MODULE=on go-fuzz-build go-fuzz

func ParseTZ

func ParseTZ(s string) (int, error)

ParseTZ parses timezone specification ("Europe/Budapest" or "+01:00") and returns the offset in seconds.


type CommonParams

type CommonParams struct {
	Username, ConnectString string
	Password                Password
	ConfigDir, LibDir       string
	// OnInit is executed on session init. Overrides AlterSession and OnInitStmts!
	OnInit func(context.Context, driver.ConnPrepareContext) error
	// OnInitStmts are executed on session init, iff OnInit is nil.
	OnInitStmts []string
	// AlterSession key-values are set with "ALTER SESSION SET key=value" on session init, iff OnInit is nil.
	AlterSession [][2]string
	Timezone     *time.Location
	// StmtCacheSize of 0 means the default, -1 to disable the stmt cache completely
	StmtCacheSize           int
	EnableEvents, NoTZCheck bool
	Charset                 string

CommonParams holds the common parameters for pooled or standalone connections.

For details, see https://oracle.github.io/odpi/doc/structs/dpiCommonCreateParams.html#dpicommoncreateparams

func (CommonParams) String

func (P CommonParams) String() string

String returns the string representation of CommonParams.

type ConnParams

type ConnParams struct {
	NewPassword                             Password
	ConnClass                               string
	IsSysDBA, IsSysOper, IsSysASM, IsPrelim bool
	ShardingKey, SuperShardingKey           []interface{}

ConnParams holds the connection-specific parameters.

For details, see https://oracle.github.io/odpi/doc/structs/dpiConnCreateParams.html#dpiconncreateparams

func (ConnParams) String

func (P ConnParams) String() string

String returns the string representation of the ConnParams.

type ConnectionParams

type ConnectionParams struct {
	// ConnParams.NewPassword is used iff StandaloneConnection is true!
	StandaloneConnection bool

ConnectionParams holds the params for a connection (pool). You can use ConnectionParams{...}.StringWithPassword() as a connection string in sql.Open.

func Parse

func Parse(dataSourceName string) (ConnectionParams, error)

Parse parses the given connection string into a struct.

For examples, see [../doc/connection.md](../doc/connection.md)

func (ConnectionParams) IsStandalone

func (P ConnectionParams) IsStandalone() bool

IsStandalone returns whether the connection should be standalone, not pooled.

func (*ConnectionParams) SetSessionParamOnInit

func (P *ConnectionParams) SetSessionParamOnInit(k, v string)

SetSessionParamOnInit adds an "ALTER SESSION k=v" to the OnInit task list.

func (ConnectionParams) String

func (P ConnectionParams) String() string

String returns the string representation of ConnectionParams. The password is replaced with a "***" string!

func (ConnectionParams) StringNoClass

func (P ConnectionParams) StringNoClass() string

StringNoClass returns the string representation of ConnectionParams, without class info. The password is replaced with a "***" string!

func (ConnectionParams) StringWithPassword

func (P ConnectionParams) StringWithPassword() string

StringWithPassword returns the string representation of ConnectionParams (as String() does), but does NOT obfuscate the password, just prints it as is.

type Password

type Password struct {
	// contains filtered or unexported fields

Password is printed obfuscated with String, use Secret to reveal the secret.

func NewPassword

func NewPassword(secret string) Password

NewPassword creates a new Password, containing the given secret.

func (*Password) CopyFrom added in v0.19.3

func (P *Password) CopyFrom(Q Password)

CopyFrom another password.

func (Password) IsZero

func (P Password) IsZero() bool

IsZero returns whether the password is emtpy.

func (Password) Len

func (P Password) Len() int

Len returns the length of the password.

func (*Password) MarshalBinary added in v0.33.1

func (P *Password) MarshalBinary() ([]byte, error)

func (*Password) MarshalJSON added in v0.33.1

func (P *Password) MarshalJSON() ([]byte, error)


func (*Password) MarshalText added in v0.33.1

func (P *Password) MarshalText() ([]byte, error)

func (*Password) Reset

func (P *Password) Reset()

Reset the password.

func (Password) Secret

func (P Password) Secret() string

Secret reveals the real password.

func (*Password) Set added in v0.19.3

func (P *Password) Set(secret string)

Set the password.

func (Password) String

func (P Password) String() string

String returns the secret obfuscated irreversibly.

type PoolParams

type PoolParams struct {
	MinSessions, MaxSessions, SessionIncrement int
	MaxSessionsPerShard                        int
	WaitTimeout, MaxLifeTime, SessionTimeout   time.Duration
	PingInterval                               time.Duration
	Heterogeneous, ExternalAuth                bool

PoolParams holds the configuration of the Oracle Session Pool.

For details, see https://oracle.github.io/odpi/doc/structs/dpiPoolCreateParams.html#dpipoolcreateparams

For details, see https://oracle.github.io/odpi/doc/structs/dpiPoolCreateParams.html#dpipoolcreateparams

func (PoolParams) String

func (P PoolParams) String() string

String returns the string representation of PoolParams.

Source Files

Jump to

Keyboard shortcuts

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