Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntShardID ¶
IntShardID is a numeric unique identifier that includes shard information
func BuildIntShardID ¶
func BuildIntShardID(shardID, typeID, localID int64) IntShardID
BuildIntShardID builds an integer ID
func ParseIntShardID ¶
func ParseIntShardID(id int64) IntShardID
ParseIntShardID parses an intID into a ShardID object
type ShardID ¶
type ShardID struct {
// contains filtered or unexported fields
}
func NewShardID ¶
func NewShardIDFromID ¶
type Sharder ¶
type Sharder struct {
// contains filtered or unexported fields
}
func NewSharder ¶
func (*Sharder) CurrentShardID ¶
func (*Sharder) NewFromString ¶
NewFromString mods the first N characters of string str against the number of shards Throws an error if str has a length of zero
func (*Sharder) NewFromSubID ¶
NewFromSubID returns a new ShardID based on some other value (subID) that is taken into account when generating the destination shard Allows for distribution of entries across shards to be dependent on some other value Usage:
// This would group blog entries into shards based on createdByUserID blogEntryID := s.NewFromSubID(createdByUserID) blogEntryID2 := s.NewFromSubID(createdByUserID) // Same shard as line above
func (*Sharder) NewRoundRobin ¶
NewRoundRobin returns a new ShardID based on an incrementing sequence integer mod the number of shards Allows for an equal distribution of entries across shards