conn

package
v0.0.0-...-214dc2d Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: PostgreSQL Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ACQUIRED = InstanceStatus("ACQUIRED")
View Source
const CANCELREQ = 80877102
View Source
const GSSREQ = 80877104
View Source
const NotInitialized = InstanceStatus("NOT_INITIALIZED")
View Source
const SSLREQ = 80877103

Variables

This section is empty.

Functions

This section is empty.

Types

type DBInstance

type DBInstance interface {
	Send(query pgproto3.FrontendMessage) error
	Receive() (pgproto3.BackendMessage, error)

	ReqBackendSsl(*tls.Config) error

	Hostname() string
	ShardName() string

	Close() error
	Status() InstanceStatus
	SetStatus(status InstanceStatus)

	Cancel(csm *pgproto3.CancelRequest) error

	Tls() *tls.Config
}

func NewInstanceConn

func NewInstanceConn(host string, shard string, tlsconfig *tls.Config) (DBInstance, error)

NewInstanceConn creates a new instance connection to a PostgreSQL database.

Parameters: - host (string): The host of the PostgreSQL database. - shard (string): The shard name of the PostgreSQL database. - tlsconfig (*tls.Config): The TLS configuration for the connection.

Return: - (DBInstance, error): The newly created instance connection and any error that occurred.

type InstanceStatus

type InstanceStatus string

type PostgreSQLInstance

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

func (*PostgreSQLInstance) Cancel

func (pgi *PostgreSQLInstance) Cancel(csm *pgproto3.CancelRequest) error

Cancel cancels a PostgreSQL query execution.

Parameters: - csm: A pointer to a pgproto3.CancelRequest struct that represents the cancel request.

Returns: - error: An error if the cancel request fails, otherwise nil.

func (*PostgreSQLInstance) Close

func (pgi *PostgreSQLInstance) Close() error

Close closes the connection of the PostgreSQLInstance. It returns an error if there was a problem closing the connection.

Parameters: - None.

Returns: - error: An error if there was a problem closing the connection.

func (*PostgreSQLInstance) Hostname

func (pgi *PostgreSQLInstance) Hostname() string

Hostname returns the hostname of the PostgreSQLInstance.

Parameters: - None.

Returns: - string: The hostname of the PostgreSQLInstance.

func (*PostgreSQLInstance) Receive

func (pgi *PostgreSQLInstance) Receive() (pgproto3.BackendMessage, error)

Receive returns a backend message received using the PostgreSQLInstance's frontend.

Parameters: - None.

Return: - pgproto3.BackendMessage: The received backend message. - error: An error if the receiving fails.

func (*PostgreSQLInstance) ReqBackendSsl

func (pgi *PostgreSQLInstance) ReqBackendSsl(tlsconfig *tls.Config) error

ReqBackendSsl requests the backend to enable SSL/TLS communication.

Parameters: - tlsconfig (*tls.Config): The TLS configuration to use for the SSL/TLS handshake.

Returns: - error: An error if there was a problem requesting the backend to enable SSL/TLS communication.

This function sends a request to the backend to enable SSL/TLS communication. It first writes a 4-byte message to the connection, indicating the length of the message and the SSLREQ constant. It then reads a single byte response from the connection. If the response is not 'S', indicating that SSL should be enabled, an error is returned. Otherwise, the connection is upgraded to use TLS using the provided TLS configuration. Finally, a debug log message is printed indicating that the backend connection has been initialized with TLS.

func (*PostgreSQLInstance) Send

Send sends a query using the PostgreSQLInstance's frontend and flushes the connection.

Parameters: - query (pgproto3.FrontendMessage): The query to send.

Return: - error: An error if the sending or flushing fails.

func (*PostgreSQLInstance) SetFrontend

func (pgi *PostgreSQLInstance) SetFrontend(f *pgproto3.Frontend)

SetFrontend sets the frontend of the PostgreSQLInstance.

Parameters: - f (*pgproto3.Frontend): the frontend to be set.

Returns: - None.

func (*PostgreSQLInstance) SetShardName

func (pgi *PostgreSQLInstance) SetShardName(name string)

SetShardName sets the shard name of the PostgreSQLInstance.

Parameters: - name (string): the name of the shard to be set.

Returns: - None.

func (*PostgreSQLInstance) SetStatus

func (pgi *PostgreSQLInstance) SetStatus(status InstanceStatus)

SetStatus sets the status of the PostgreSQLInstance.

Parameters: - status (InstanceStatus): a new status of the instance.

Returns: - None.

func (*PostgreSQLInstance) ShardName

func (pgi *PostgreSQLInstance) ShardName() string

ShardName returns the shard name of the PostgreSQLInstance.

Parameters: - None.

Returns: - string: The shard name of the PostgreSQLInstance.

func (*PostgreSQLInstance) Status

func (pgi *PostgreSQLInstance) Status() InstanceStatus

Status returns the status of the PostgreSQLInstance.

Parameters: - None.

Returns: - InstanceStatus.

func (*PostgreSQLInstance) Tls

func (pgi *PostgreSQLInstance) Tls() *tls.Config

Tls returns the TLS configuration of the PostgreSQLInstance.

Parameters: - None.

Returns: - *tls.Config: The TLS configuration of the PostgreSQLInstance.

type RawConn

type RawConn interface {
	net.Conn
}

Jump to

Keyboard shortcuts

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