Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Pmgr session.SessionParamsHolder ID() uint ReplyErrMsg(e string, c string) error ReplyErrMsgByCode(code string) error ReplyErr(errmsg error) error ReplyRFQ(txstatus txstatus.TXStatus) error ReplyNotice(message string) error ReplyDebugNotice(msg string) error ReplyDebugNoticef(fmt string, args ...interface{}) error ReplyWarningMsg(msg string) error ReplyWarningf(fmt string, args ...interface{}) 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 DB() string Send(msg pgproto3.BackendMessage) error SendCtx(ctx context.Context, msg pgproto3.BackendMessage) error Receive() (pgproto3.FrontendMessage, error) ReceiveCtx(ctx context.Context) (pgproto3.FrontendMessage, error) Shutdown() error Reset() error Close() error Shards() []shard.Shard Cancel() error Reply(msg string) error SetAuthType(uint32) error }
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 Pool ¶
type Pool interface { ClientPoolForeach(cb func(client ClientInfo) error) error Put(client Client) error Pop(id uint) (bool, error) Shutdown() error }
func NewClientPool ¶
func NewClientPool() Pool
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) 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) 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.