Documentation
¶
Index ¶
- Constants
- type Client
- type ClientInfo
- type ClientInfoImpl
- type InteractRunner
- type ParamManager
- type Pool
- type PoolImpl
- func (c *PoolImpl) ClientPoolForeach(cb func(client ClientInfo) error) error
- func (c *PoolImpl) ErrorCounts() map[string]uint64
- func (c *PoolImpl) Pop(id uint) (bool, error)
- func (c *PoolImpl) Put(client Client) error
- func (c *PoolImpl) ReportError(errtype string)
- func (c *PoolImpl) Shutdown() error
- func (c *PoolImpl) StartBackgroundHealthCheck()
Constants ¶
const (
DefaultClientDeadCheckInterval = time.Duration(time.Second * 15)
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
ParamManager
session.SessionParamsHolder
statistics.StatHolder
ID() uint
ReplyErrWithTxStatus(e error, s txstatus.TXStatus) error
ReplyErrMsgByCode(code string) error
ReplyErr(errmsg error) error
ReplyErrMsgPure(errmsg error) error
ReplyRFQ(txstatus txstatus.TXStatus) error
ReplyNotice(message string) error
ReplyDebugNotice(msg string) error
ReplyDebugNoticef(fmt string, args ...any) error
ReplyWarningMsg(code string, msg string) error
ReplyWarningf(code string, fmt string, args ...any) error
DefaultReply() error
Init(cfg *tls.Config) error
/* password clear text */
PasswordCT() (string, error)
PasswordMD5(salt [4]byte) (string, error)
StartupMessage() *pgproto3.StartupMessage
Usr() string
/* XXX: also maybe ROLE support is meaningful? */
DB() string
Send(msg pgproto3.BackendMessage) error
Receive() (pgproto3.FrontendMessage, error)
/* Await and parse next message, but do not "Receive" it */
Peek() (pgproto3.FrontendMessage, error)
Flush() error
Shutdown() error
Reset() error
Close() error
Shards() []shard.ShardHostInstance
Cancel() error
/* Returns list of resource (connection) IDs, associated with this client */
CancellableIDs() []uint32
CancelPID() uint32
CancelMsg() *pgproto3.CancelRequest
Reply(msg string) error
Conn() net.Conn
SetAuthType(uint32) error
SetErrCounter(errcounter.ErrCounter)
// [icp.ICPContextHolder] support functions
Wait()
Wake()
}
type ClientInfo ¶
type ClientInfoImpl ¶
type ClientInfoImpl struct {
Client
// contains filtered or unexported fields
}
func (ClientInfoImpl) RAddr ¶
func (rci ClientInfoImpl) RAddr() string
RAddr returns the remote address of the ClientInfoImpl object.
Parameters: - None.
Returns: - string: A string representing the remote address.
type InteractRunner ¶
type ParamManager ¶
type Pool ¶
type Pool interface {
errcounter.ErrCounter
ClientPoolForeach(cb func(client ClientInfo) error) error
Put(client Client) error
Pop(id uint) (bool, error)
Shutdown() error
}
func NewClientPool ¶
NewClientPool creates a new instance of the PoolImpl struct, which implements the Pool interface.
It initializes the pool map with an empty map and the mutex with a new sync.Mutex. The function returns a pointer to the newly created PoolImpl instance.
Parameters: - None.
Returns: - Pool: A pointer to the newly created PoolImpl instance.
type PoolImpl ¶
type PoolImpl struct {
// contains filtered or unexported fields
}
func (*PoolImpl) ClientPoolForeach ¶
func (c *PoolImpl) ClientPoolForeach(cb func(client ClientInfo) error) error
ClientPoolForeach iterates over all clients in the client pool and executes the provided function for each client.
The provided function should have the following signature:
func(clientID uint, client Client) error
Parameters:
- f (func): The function to be executed for each client.
Returns:
- error: An error if any occurred during the iteration.
func (*PoolImpl) ErrorCounts ¶
ErrorCounts implements Pool.
func (*PoolImpl) Pop ¶
Pop removes a client with the specified ID from the client pool.
It first acquires a write lock on the mutex to ensure exclusive access to the pool. Then, it checks if a client with the specified ID exists in the pool. If it does, it closes the client, removes it from the pool, and returns true and nil. Otherwise, it returns false and nil.
Parameters:
- id (uint): The ID of the client to be removed from the pool.
Returns:
- ok: A boolean indicating whether the client was successfully removed from the pool.
- error: An error if any occurred during the process, including context cancellation or timeout.
func (*PoolImpl) Put ¶
Put adds a client to the client pool.
It acquires a write lock on the mutex to ensure exclusive access to the pool. Then, it adds the provided client to the pool using the client's ID as the key. Finally, it releases the lock and returns nil.
Parameters:
- client (Client): The client to be added to the pool.
Returns:
- error: An error if any occurred during the process.
func (*PoolImpl) ReportError ¶
ReportError implements Pool.
func (*PoolImpl) Shutdown ¶
Shutdown shuts down the client pool by closing all clients and releasing associated resources.
It iterates over all clients in the pool, closes each client, and then clears the pool.
Parameters: - None.
Returns:
- error: An error if any occurred during the shutdown process.
func (*PoolImpl) StartBackgroundHealthCheck ¶
func (c *PoolImpl) StartBackgroundHealthCheck()
StartBackgroundHealthCheck starts background health checking for disconnected clients