Documentation ¶
Index ¶
- func NewShard(key kr.ShardKey, pgi conn.DBInstance, cfg *config.Shard, ...) (shard.Shard, error)
- type Conn
- func (sh *Conn) Auth(sp *startup.StartupParams) error
- func (sh *Conn) AuthRule() *config.AuthBackendCfg
- func (sh *Conn) Cancel() error
- func (sh *Conn) Cfg() *config.Shard
- func (sh *Conn) Cleanup(rule *config.FrontendRule) error
- func (sh *Conn) Close() error
- func (sh *Conn) DB() string
- func (sh *Conn) DataPending() bool
- func (srv *Conn) HasPrepareStatement(hash uint64) (bool, *prepstatement.PreparedStatementDescriptor)
- func (sh *Conn) ID() uint
- func (sh *Conn) Instance() conn.DBInstance
- func (sh *Conn) InstanceHostname() string
- func (sh *Conn) ListPreparedStatements() []shard.PreparedStatementsMgrDescriptor
- func (sh *Conn) Name() string
- func (sh *Conn) Params() shard.ParameterSet
- func (sh *Conn) Pid() uint32
- func (sh *Conn) Receive() (pgproto3.BackendMessage, error)
- func (sh *Conn) RequestData()
- func (sh *Conn) SHKey() kr.ShardKey
- func (sh *Conn) Send(query pgproto3.FrontendMessage) error
- func (sh *Conn) SetTxStatus(tx txstatus.TXStatus)
- func (sh *Conn) ShardKeyName() string
- func (srv *Conn) StorePrepareStatement(hash uint64, def *prepstatement.PreparedStatementDefinition, ...)
- func (sh *Conn) String() string
- func (sh *Conn) Sync() int64
- func (sh *Conn) TxServed() int64
- func (sh *Conn) TxStatus() txstatus.TXStatus
- func (sh *Conn) Usr() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewShard ¶
func NewShard( key kr.ShardKey, pgi conn.DBInstance, cfg *config.Shard, beRule *config.BackendRule, sp *startup.StartupParams) (shard.Shard, error)
NewShard creates a new shard with the provided key, database instance, configuration, and backend rule.
Parameters: - key (kr.ShardKey): The shard key. - pgi (conn.DBInstance): The database instance. - cfg (*config.Shard): The configuration for the shard. - beRule (*config.BackendRule): The backend rule for the shard.
Returns: - shard.Shard: The newly created shard. - error: An error, if any.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) AuthRule ¶
func (sh *Conn) AuthRule() *config.AuthBackendCfg
AuthRule returns the backend auth configuration of the Conn object.
Parameters: - None.
Returns: - config.AuthBackendCfg: the configuration config.
func (*Conn) Cancel ¶
Cancel cancels the current operation on the Conn struct.
Parameters: - None.
Returns: - error: An error if the cancel operation fails.
func (*Conn) Cfg ¶
Cfg returns the shard configuration.
Parameters: - None.
Returns: - *config.Shard: The shard configuration.
func (*Conn) Cleanup ¶
func (sh *Conn) Cleanup(rule *config.FrontendRule) error
Cleanup cleans up the connection based on the provided rule.
Parameters: - rule (*config.FrontendRule): a pointer to a config.FrontendRule object that contains the cleanup rules.
Returns: - error: an error if there was a problem during cleanup, otherwise nil.
func (*Conn) Close ¶
Close closes the connection to the database. It returns an error if there was a problem closing the connection.
Parameters: - None.
Returns: - error: An error if the connection could not be closed.
func (*Conn) DB ¶
DB returns the database associated with the Conn struct.
Parameters: - None.
Returns: - string: The database associated with the Conn struct.
func (*Conn) DataPending ¶
func (*Conn) HasPrepareStatement ¶
func (srv *Conn) HasPrepareStatement(hash uint64) (bool, *prepstatement.PreparedStatementDescriptor)
HasPrepareStatement checks if a prepared statement with the given hash exists in the Conn object.
Parameters: - hash (uint64): the hash of the prepared statement.
Returns: - bool: true if the prepared statement exists, false otherwise. - *shard.PreparedStatementDescriptor: the prepared statement descriptor, or nil if it does not exist.
func (*Conn) ID ¶
ID returns the unique identifier of the Conn struct.
It returns an unsigned integer representing the ID of the Conn struct.
Parameters: - None.
Returns: - uint: The unique identifier of the Conn struct.
func (*Conn) Instance ¶
func (sh *Conn) Instance() conn.DBInstance
Instance returns the dedicated database instance associated with the Conn struct.
Parameters: - None.
Returns: - conn.DBInstance: The dedicated database instance.
func (*Conn) InstanceHostname ¶
InstanceHostname returns the hostname of the instance associated with the Conn struct.
It does this by calling the Instance() method of the Conn struct, which returns a pointer to a DBInstance struct. Then, it calls the Hostname() method of the DBInstance struct to retrieve the hostname.
Parameters: - None.
Returns: - string: The hostname of the instance associated with the Conn struct.
func (*Conn) ListPreparedStatements ¶
func (sh *Conn) ListPreparedStatements() []shard.PreparedStatementsMgrDescriptor
ListPreparedStatements implements shard.Shard.
func (*Conn) Name ¶
Name returns the name of the Conn struct as a string.
Parameters: - None.
Returns: - string: The name of the Conn struct.
func (*Conn) Params ¶
func (sh *Conn) Params() shard.ParameterSet
Params returns the ParameterSet associated with the Conn struct.
Parameters: - None.
Returns: - shard.ParameterSet: The ParameterSet associated with the Conn struct.
func (*Conn) Receive ¶
func (sh *Conn) Receive() (pgproto3.BackendMessage, error)
Receive receives a backend message from the connection.
Parameters: - None.
Returns: - pgproto3.BackendMessage: The received backend message. - error: An error if the message cannot be received.
func (*Conn) RequestData ¶
func (sh *Conn) RequestData()
func (*Conn) SHKey ¶
SHKey returns the ShardKey associated with the Conn struct.
It returns a ShardKey struct with the Name field set to the value of the Conn struct's name field.
Parameters: - None.
Returns: - kr.ShardKey: The ShardKey struct with the Name field set to the Conn struct's name field.
func (*Conn) Send ¶
func (sh *Conn) Send(query pgproto3.FrontendMessage) error
Send sends a FrontendMessage to the shard connection.
Parameters: - query (pgproto3.FrontendMessage): The query to be sent.
Returns: - error: An error if the message cannot be sent.
func (*Conn) SetTxStatus ¶
SetTxStatus sets the transaction status of the Conn object.
Parameters: - tx (txstatus.TXStatus): the transaction status to be set.
Returns:
- None.
func (*Conn) ShardKeyName ¶
ShardKeyName returns the name of the shard key.
It returns the name of the shard key by calling the SHKey method of the Conn struct and accessing the Name field of the returned ShardKey struct.
Parameters: - None.
Returns: - string: The name of the shard key.
func (*Conn) StorePrepareStatement ¶
func (srv *Conn) StorePrepareStatement(hash uint64, def *prepstatement.PreparedStatementDefinition, rd *prepstatement.PreparedStatementDescriptor)
PrepareStatement adds a prepared statement to the Conn object.
Parameters: - hash (uint64): the hash of the prepared statement. - rd (*shard.PreparedStatementDescriptor): the prepared statement descriptor.
Returns: - None.
func (*Conn) String ¶
String returns the name of the Conn struct as a string.
Parameters: - None.
Returns: - string: The name of the Conn struct.
func (*Conn) Sync ¶
Sync returns the difference between the sync_out and sync_in fields of the Conn struct.
Parameters: - None.
Returns: - int64: The difference between sync_out and sync_in.
func (*Conn) TxServed ¶
TxServed returns the number of transactions served by the Conn struct.
Parameters: - None.
Returns: - int64: The number of transactions served.