Documentation
¶
Index ¶
- type ShardManager
- func (s *ShardManager) Close(ctx context.Context) error
- func (s *ShardManager) Ping(ctx context.Context) error
- func (s *ShardManager) SetShardIndexFunc(ctx context.Context, f func(key any, count int) (int, error))
- func (s *ShardManager) Shard(ctx context.Context, key any) (*pgxpool.Pool, error)
- func (s *ShardManager) Shards(ctx context.Context) ([]*pgxpool.Pool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ShardManager ¶
type ShardManager struct {
// contains filtered or unexported fields
}
ShardManager manages a set of database shards and provides methods to interact with them.
func New ¶
func New(ctx context.Context, connectionStrings []string) (*ShardManager, error)
New creates a new ShardManager instance by initializing connections to the provided database connection strings. It returns an error if any connection fails.
func (*ShardManager) Close ¶
func (s *ShardManager) Close(ctx context.Context) error
Close closes all the database connections managed by the ShardManager.
func (*ShardManager) Ping ¶
func (s *ShardManager) Ping(ctx context.Context) error
Ping checks the connectivity of all shards by pinging each one. It returns an error if any shard is unreachable.
func (*ShardManager) SetShardIndexFunc ¶
func (s *ShardManager) SetShardIndexFunc(ctx context.Context, f func(key any, count int) (int, error))
SetShardIndexFunc sets a custom shard index function to determine which shard to use based on the provided key.
Click to show internal directories.
Click to hide internal directories.