shard

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 2 Imported by: 2

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

type ShardConfig struct {
	ShardId  uint64 `json:"shardId"`
	NumShard uint64 `json:"numShard"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL