Documentation ¶
Index ¶
- Constants
- type DBInstance
- type InstanceStatus
- type PostgreSQLInstance
- func (pgi *PostgreSQLInstance) AvailabilityZone() string
- func (pgi *PostgreSQLInstance) Cancel(csm *pgproto3.CancelRequest) error
- func (pgi *PostgreSQLInstance) Close() error
- func (pgi *PostgreSQLInstance) Hostname() string
- func (pgi *PostgreSQLInstance) Receive() (pgproto3.BackendMessage, error)
- func (pgi *PostgreSQLInstance) ReqBackendSsl(tlsconfig *tls.Config) error
- func (pgi *PostgreSQLInstance) Send(query pgproto3.FrontendMessage) error
- func (pgi *PostgreSQLInstance) SetFrontend(f *pgproto3.Frontend)
- func (pgi *PostgreSQLInstance) SetShardName(name string)
- func (pgi *PostgreSQLInstance) SetStatus(status InstanceStatus)
- func (pgi *PostgreSQLInstance) ShardName() string
- func (pgi *PostgreSQLInstance) Status() InstanceStatus
- func (pgi *PostgreSQLInstance) Tls() *tls.Config
- type RawConn
Constants ¶
const ACQUIRED = InstanceStatus("ACQUIRED")
const CANCELREQ = 80877102
const GSSREQ = 80877104
const NotInitialized = InstanceStatus("NOT_INITIALIZED")
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 AvailabilityZone() string ShardName() string Close() error Status() InstanceStatus SetStatus(status InstanceStatus) Cancel(csm *pgproto3.CancelRequest) error Tls() *tls.Config }
func NewInstanceConn ¶
func NewInstanceConn(host string, availabilityZone string, shardname string, tlsconfig *tls.Config, timeout time.Duration, keepAlive time.Duration, tcpUserTimeout time.Duration) (DBInstance, error)
NewInstanceConn creates a new instance connection to a PostgreSQL database.
Parameters: - host (string): The hostname of the PostgreSQL instance. - availabilityZone (string): The availability zone of the PostgreSQL instance. - shardname (string): The name of the shard. - tlsconfig (*tls.Config): The TLS configuration to use for the SSL/TLS handshake. - timeout (time.Duration): The timeout for the connection. - keepAlive (time.Duration): The keep alive duration for the connection. - tcpUserTimeout (time.Duration): The TCP user timeout duration for the connection.
Returns: - DBInstance: The new PostgreSQLInstance. - error: An error if there was a problem creating the new PostgreSQLInstance.
type InstanceStatus ¶
type InstanceStatus string
type PostgreSQLInstance ¶
type PostgreSQLInstance struct {
// contains filtered or unexported fields
}
func (*PostgreSQLInstance) AvailabilityZone ¶
func (pgi *PostgreSQLInstance) AvailabilityZone() string
AvailabilityZone returns the availability zone of the PostgreSQLInstance.
Parameters: - None.
Returns: - string: The availability zone of the PostgreSQLInstance.
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 ¶
func (pgi *PostgreSQLInstance) Send(query pgproto3.FrontendMessage) error
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.