datashard

package
v0.0.0-...-096c525 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: PostgreSQL Imports: 12 Imported by: 0

Documentation

Index

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) Auth

func (sh *Conn) Auth(sp *startup.StartupParams) error

TODO : unit tests

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

func (sh *Conn) Cancel() error

Cancel cancels the current operation on the Conn struct.

Parameters: - None.

Returns: - error: An error if the cancel operation fails.

func (*Conn) Cfg

func (sh *Conn) Cfg() *config.Shard

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

func (sh *Conn) Close() error

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

func (sh *Conn) DB() string

DB returns the database associated with the Conn struct.

Parameters: - None.

Returns: - string: The database associated with the Conn struct.

func (*Conn) DataPending

func (sh *Conn) DataPending() bool

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

func (sh *Conn) ID() uint

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

func (sh *Conn) InstanceHostname() string

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

func (sh *Conn) Name() string

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) Pid

func (sh *Conn) Pid() uint32

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

func (sh *Conn) SHKey() kr.ShardKey

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

func (sh *Conn) SetTxStatus(tx txstatus.TXStatus)

SetTxStatus sets the transaction status of the Conn object.

Parameters: - tx (txstatus.TXStatus): the transaction status to be set.

Returns:

  • None.

func (*Conn) ShardKeyName

func (sh *Conn) ShardKeyName() string

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

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

func (sh *Conn) String() 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

func (sh *Conn) Sync() int64

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

func (sh *Conn) TxServed() int64

TxServed returns the number of transactions served by the Conn struct.

Parameters: - None.

Returns: - int64: The number of transactions served.

func (*Conn) TxStatus

func (sh *Conn) TxStatus() txstatus.TXStatus

TxStatus returns the transaction status of the Conn object.

Parameters: - None.

Returns: - txstatus.TXStatus: the transaction status.

func (*Conn) Usr

func (sh *Conn) Usr() string

Usr returns the username associated with the Conn struct.

Parameters: - None.

Returns: - string: The username from auth config or associated with the Conn struct.

Jump to

Keyboard shortcuts

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