Documentation ¶
Index ¶
- type IShortSharder
- type IntShardID
- type ShardID
- type Sharder
- func (s *Sharder) CurrentShardID() int64
- func (s *Sharder) GetShardFromSubID(subID int64) int64
- func (s *Sharder) NewFromString(str string) (shardID *ShardID, e error)
- func (s *Sharder) NewFromSubID(subID int64) *ShardID
- func (s *Sharder) NewRoundRobin() *ShardID
- func (s *Sharder) NumberOfShards() int64
- type ShortShardID
- type ShortSharder
- func (s *ShortSharder) CurrentShardID() int64
- func (s *ShortSharder) GetShardFromString(str string) (int64, error)
- func (s *ShortSharder) GetShardFromSubID(subID int64) int64
- func (s *ShortSharder) NewFromString(str string) (shardID *ShortShardID, e error)
- func (s *ShortSharder) NewFromSubID(subID int64) *ShortShardID
- func (s *ShortSharder) NewRoundRobin() *ShortShardID
- func (s *ShortSharder) NumberOfShards() int64
- type StringShardID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IShortSharder ¶ added in v1.8.21
type IShortSharder interface { NewRoundRobin() *ShortShardID NewFromSubID(subID int64) *ShortShardID }
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) GetShardFromSubID ¶ added in v1.8.8
GetShardFromSubID returns the shard number without incrementing the internal sequence
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
func (*Sharder) NumberOfShards ¶
type ShortShardID ¶ added in v1.8.17
type ShortShardID struct {
// contains filtered or unexported fields
}
func NewShortShardID ¶ added in v1.8.17
func NewShortShardID(shard int64) *ShortShardID
func NewShortShardIDFromID ¶ added in v1.8.17
func NewShortShardIDFromID(id int64) *ShortShardID
func (*ShortShardID) Hash ¶ added in v1.8.17
func (s *ShortShardID) Hash() uint32
hash does an FNV1a hash of the string
func (*ShortShardID) ID ¶ added in v1.8.17
func (s *ShortShardID) ID() int64
ID returns the id of the shard
func (*ShortShardID) Shard ¶ added in v1.8.17
func (s *ShortShardID) Shard() int64
func (*ShortShardID) String ¶ added in v1.8.17
func (s *ShortShardID) String() string
func (*ShortShardID) Timestamp ¶ added in v1.8.17
func (s *ShortShardID) Timestamp() int64
type ShortSharder ¶ added in v1.8.17
type ShortSharder struct {
// contains filtered or unexported fields
}
func NewShortSharder ¶ added in v1.8.17
func NewShortSharder(numberOfShards int64) *ShortSharder
func (*ShortSharder) CurrentShardID ¶ added in v1.8.17
func (s *ShortSharder) CurrentShardID() int64
func (*ShortSharder) GetShardFromString ¶ added in v1.8.27
func (s *ShortSharder) GetShardFromString(str string) (int64, error)
GetShardFromString returns the shard number without incrementing the internal sequence
func (*ShortSharder) GetShardFromSubID ¶ added in v1.8.17
func (s *ShortSharder) GetShardFromSubID(subID int64) int64
GetShardFromSubID returns the shard number without incrementing the internal sequence
func (*ShortSharder) NewFromString ¶ added in v1.8.17
func (s *ShortSharder) NewFromString(str string) (shardID *ShortShardID, e error)
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 (*ShortSharder) NewFromSubID ¶ added in v1.8.17
func (s *ShortSharder) NewFromSubID(subID int64) *ShortShardID
NewFromSubID returns a new ShortShardID 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 (*ShortSharder) NewRoundRobin ¶ added in v1.8.17
func (s *ShortSharder) NewRoundRobin() *ShortShardID
NewRoundRobin returns a new ShortShardID based on an incrementing sequence integer mod the number of shards Allows for an equal distribution of entries across shards
func (*ShortSharder) NumberOfShards ¶ added in v1.8.17
func (s *ShortSharder) NumberOfShards() int64