Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckReplica ¶
func CheckReplica(shardConfigs []*ShardConfig, expectedReplica uint) bool
Types ¶
type ShardConfig ¶
func (*ShardConfig) HasSegment ¶
func (config *ShardConfig) HasSegment(segmentIndex uint64) bool
func (*ShardConfig) IsValid ¶
func (config *ShardConfig) IsValid() bool
func (*ShardConfig) NextSegmentIndex ¶ added in v0.6.2
func (config *ShardConfig) NextSegmentIndex(startSegmentIndex uint64) uint64
NextSegmentIndex calculates the next segment index for the shard, starting from the given startSegmentIndex. If the startSegmentIndex is already covered by the shard (i.e., the shard is responsible for this segment), it will be included in the result and returned directly. Otherwise, the function will calculate and return the next segment index that this shard is responsible for.
type ShardedNode ¶
type ShardedNode struct { URL string `json:"url"` Config ShardConfig `json:"config"` // Latency RPC latency in milli seconds. Latency int64 `json:"latency"` // Since last updated timestamp. Since int64 `json:"since"` }
func NewShardNodesFromConfig ¶ added in v0.6.2
func NewShardNodesFromConfig(configs []*ShardConfig) []*ShardedNode
func Select ¶
func Select(nodes []*ShardedNode, expectedReplica uint, random bool) ([]*ShardedNode, bool)
select a set of given sharded node and make the data is replicated at least expctedReplica times return the selected nodes and if selection is successful
Click to show internal directories.
Click to hide internal directories.