Documentation ¶
Overview ¶
Package shardingbirdsnest sharding bird's nest configuration
Package shardingbirdsnest interface ¶
Package shardingbirdsnest serialize ¶
Package shardingbirdsnest sharding algorithm ¶
Package shardingbirdsnest bird's nest
Index ¶
- Constants
- Variables
- func ChecksumKeyModulo(key bn.Key, length int) int
- type KeyModuloAlgorithm
- type ModuloShardingAlgorithm
- type ShardingAlgorithm
- type ShardingBirdsNest
- func (s *ShardingBirdsNest) Add(key bn.Key) error
- func (s *ShardingBirdsNest) Adds(keys []bn.Key) (err error)
- func (s *ShardingBirdsNest) AddsAndSetHeight(keys []bn.Key, height uint64) (result error)
- func (s *ShardingBirdsNest) Contains(key bn.Key, rules ...bn.RuleType) (bool, error)
- func (s *ShardingBirdsNest) Deserialize() error
- func (s *ShardingBirdsNest) GetHeight() uint64
- func (s *ShardingBirdsNest) Info() []uint64
- func (s *ShardingBirdsNest) Infos() [][]uint64
- func (s *ShardingBirdsNest) Serialize() error
- func (s *ShardingBirdsNest) SetHeight(height uint64)
- func (s *ShardingBirdsNest) Start()
- func (s *ShardingBirdsNest) ValidateRule(key bn.Key, rules ...bn.RuleType) error
- type ShardingBirdsNestConfig
Constants ¶
const (
// Filepath sharding path
Filepath = "sharding"
)
Variables ¶
var ( // ErrAddsTimeout adds timeout error ErrAddsTimeout = errors.New("add multiple key timeout") // ErrCannotModifyTheNestConfiguration cannot modify the nest configuration ErrCannotModifyTheNestConfiguration = errors.New("when historical data exists, you cannot modify the nest " + "configuration") )
Functions ¶
Types ¶
type KeyModuloAlgorithm ¶
KeyModuloAlgorithm key modulo algorithm
type ModuloShardingAlgorithm ¶
type ModuloShardingAlgorithm struct { // Length Length int }
ModuloShardingAlgorithm sharding modulo algorithm
func NewModuloSA ¶
func NewModuloSA(l int) *ModuloShardingAlgorithm
NewModuloSA new sharding modulo algorithm
func (ModuloShardingAlgorithm) DoSharding ¶
func (a ModuloShardingAlgorithm) DoSharding(shardingValues []bn.Key) [][]bn.Key
DoSharding 如果传入 shardingValues 小于 Length 则 最小设置为1
func (ModuloShardingAlgorithm) DoShardingOnce ¶
func (a ModuloShardingAlgorithm) DoShardingOnce(key bn.Key) (index int)
DoShardingOnce do once sharding key
type ShardingAlgorithm ¶
type ShardingAlgorithm interface { // DoSharding do sharding DoSharding(shardingValues []bn.Key) [][]bn.Key // DoShardingOnce once sharding DoShardingOnce(bn.Key) (index int) }
ShardingAlgorithm sharding algorithm
type ShardingBirdsNest ¶
type ShardingBirdsNest struct {
// contains filtered or unexported fields
}
ShardingBirdsNest Sharding bird's nest implement
func NewShardingBirdsNest ¶
func NewShardingBirdsNest(config *ShardingBirdsNestConfig, exitC chan struct{}, strategy bn.Strategy, alg ShardingAlgorithm, logger bn.Logger) (*ShardingBirdsNest, error)
NewShardingBirdsNest new sharding bird's nest implement
func (*ShardingBirdsNest) Adds ¶
func (s *ShardingBirdsNest) Adds(keys []bn.Key) (err error)
Adds add keys
func (*ShardingBirdsNest) AddsAndSetHeight ¶
func (s *ShardingBirdsNest) AddsAndSetHeight(keys []bn.Key, height uint64) (result error)
AddsAndSetHeight Adds and SetHeight
func (*ShardingBirdsNest) Contains ¶
Contains bn.Key
func (*ShardingBirdsNest) Deserialize ¶
func (s *ShardingBirdsNest) Deserialize() error
Deserialize deserialize configuration
func (*ShardingBirdsNest) GetHeight ¶
func (s *ShardingBirdsNest) GetHeight() uint64
GetHeight get current height
func (*ShardingBirdsNest) Info ¶
func (s *ShardingBirdsNest) Info() []uint64
Info print sharding bird's nest info
func (*ShardingBirdsNest) Infos ¶
func (s *ShardingBirdsNest) Infos() [][]uint64
Infos print sharding bird's nest info index 0 sharding index index 0 height index 1 cuckoo size index 2 current index index 3 total cuckoo size index 4 total space occupied by cuckoo
func (*ShardingBirdsNest) Serialize ¶
func (s *ShardingBirdsNest) Serialize() error
Serialize serialize to wal
func (*ShardingBirdsNest) SetHeight ¶
func (s *ShardingBirdsNest) SetHeight(height uint64)
SetHeight set current height
func (*ShardingBirdsNest) Start ¶
func (s *ShardingBirdsNest) Start()
Start TODO Goroutinue should be turned off using context.Context here
type ShardingBirdsNestConfig ¶ added in v2.3.0
type ShardingBirdsNestConfig struct { // ChainId ChainId string `json:"chain_id,omitempty"` // Length bird's nest numbers Length uint32 `json:"length,omitempty"` // Timeout sharding task timeout Timeout int64 `json:"timeout,omitempty"` // Birdsnest Bird's Nest configuration Birdsnest *bn.BirdsNestConfig `json:"birdsnest,omitempty"` // Snapshot configuration Snapshot *bn.SnapshotSerializerConfig `json:"snapshot,omitempty"` }
ShardingBirdsNestConfig Sharding bird's Nest configuration