Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster[KeyType ID, ConnType any] interface { // All returns all shards. All() []Shard[ConnType] // One returns Shard by key. One(key KeyType) Shard[ConnType] // Each runs fn on each shard within cluster. Each(fn func(s Shard[ConnType]) error) error // Map takes a list of identifiers and returns a map[] where the key is the corresponding // shard and the value is a slice of ids that belong to shard. Map(ids []KeyType) map[Shard[ConnType]][]KeyType // ByKeys executes fn on each result of Map func. ByKeys(ids []KeyType, fn func([]KeyType, Shard[ConnType]) error) error }
Cluster interface.
type Config ¶
type Config[KeyType ID, ConnType any] struct { Connect ConnectFunc[ConnType] // required. connection func Shards []ShardConfig // required. shards config. Context context.Context // optional. defaults to context.Background() Strategy Strategy[KeyType, ConnType] // optional. defaults to defaultStrategy. }
Config struct.
type ConnectFunc ¶
ConnectFunc wraps connection func.
type ShardConfig ¶
ShardConfig type include constant connection id and dsn.
func ShardsConfigFromEnv ¶
func ShardsConfigFromEnv(prefix ...string) []ShardConfig
ShardsConfigFromEnv loads parses environment variables and searches for variables called [prefix_]SHARD_ADDRESS_n, where prefix is optional and n is an increment number.
Click to show internal directories.
Click to hide internal directories.