types

package
v1.7.11 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectorOption added in v1.5.0

type ConnectorOption func(*ConnectorOptions)

ConnectorOption is the 'functional option' complement to ConnectorOptions

type ConnectorOptions added in v1.5.0

type ConnectorOptions struct {
	Logger                log.Logger
	NewMSSQLConnector     MSSQLConnectorCtor
	ReadPreloginRequest   ReadPreloginRequestFunc
	WritePreloginResponse WritePreloginResponseFunc
	ReadLoginRequest      ReadLoginRequestFunc
	WriteError            WriteErrorFunc
	NewTdsBuffer          TdsBufferCtor
}

ConnectorOptions captures all the configuration options for a SingleUseConnector

type MSSQLConnector

type MSSQLConnector interface {
	Connect(context.Context) (net.Conn, error)
}

MSSQLConnector captures the part of the 3rd party driver's mssql.Connector type that we care about -- its "Connect" method -- in an interface. This allows us to mock that in our unit tests.

type MSSQLConnectorCtor

type MSSQLConnectorCtor func(dsn string) (MSSQLConnector, error)

MSSQLConnectorCtor represents the constructor of an mssqlConnector. It exists so that its production implementation (mssql.NewConnector) can be swapped out in unit tests. Note we keep MSSQL in the name to prevent confusion with the Secretless Connector.

type MSSQLConnectorFunc

type MSSQLConnectorFunc func(context.Context) (net.Conn, error)

MSSQLConnectorFunc lets us treat a function (that matches the "Connect" signature) as an MSSQLConnector interface.

func (MSSQLConnectorFunc) Connect

func (fn MSSQLConnectorFunc) Connect(ctx context.Context) (net.Conn, error)

Connect implements the MSSQLConnector interface.

type ReadLoginRequestFunc added in v1.5.0

type ReadLoginRequestFunc func(r io.ReadWriteCloser) (*mssql.LoginRequest, error)

ReadLoginRequestFunc defines the type of the func that reads the client's login packet. The production version is implemented by mssql.ReadLoginRequest.

type ReadPreloginRequestFunc added in v1.5.0

type ReadPreloginRequestFunc func(
	r io.ReadWriteCloser,
) (map[uint8][]byte, error)

ReadPreloginRequestFunc defines the type of the func that reads the prelogin packet. The production version is implemented by mssql.ReadPreloginRequest.

type TdsBufferCtor

type TdsBufferCtor func(transport io.ReadWriteCloser) io.ReadWriteCloser

TdsBufferCtor represents the constructor of a TdsBuffer, in a form suitable for unit tests.

Note the signature does not mention TdsBuffers. This is because our code is only concerned with the ReadWriteCloser closer functionality, and our doubles can be ReadWriteClosers. The production implementation needs of course to return a real TdsBuffer (which _is_ a ReadWriteCloser), and so we've chosen a name that reflects the production purpose.

type WriteErrorFunc added in v1.5.0

type WriteErrorFunc func(
	w io.ReadWriteCloser,
	err mssql.Error,
) error

WriteErrorFunc defines the type of the func that writes an error packet. The production version is implemented by mssql.WriteError.

type WritePreloginResponseFunc added in v1.5.0

type WritePreloginResponseFunc func(
	w io.ReadWriteCloser,
	fields map[uint8][]byte,
) error

WritePreloginResponseFunc defines the type of the func that writes the prelogin response packet. The production version is implemented by mssql.WritePreloginResponse.

Jump to

Keyboard shortcuts

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