Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewShardingBlobAccess ¶
func NewShardingBlobAccess(backends []blobstore.BlobAccess, shardPermuter ShardPermuter, storageType blobstore.StorageType, hashInitialization uint64) blobstore.BlobAccess
NewShardingBlobAccess is an adapter for BlobAccess that partitions requests across backends by hashing the digest. A ShardPermuter is used to map hashes to backends.
Types ¶
type ShardPermuter ¶
type ShardPermuter interface {
GetShard(hash uint64, selector ShardSelector)
}
ShardPermuter is an algorithm for turning a hash into a series of indices corresponding to backends capable of serving blobs corresponding with that hash.
As backends may be unavailable (e.g., drained) or replication strategies may be applied to duplicate blobs, it is important that an actual permutation is returned to ensure every backend is given a chance. It is permitted to spuriously generate the same index multiple times.
func NewWeightedShardPermuter ¶
func NewWeightedShardPermuter(weights []uint32) ShardPermuter
NewWeightedShardPermuter is a shard selection algorithm that generates a permutation of [0, len(weights)) for every hash, where every index i is returned weights[i] times. This makes it possible to have storage backends with different specifications in terms of capacity and throughput, giving them a proportional amount of traffic.
type ShardSelector ¶
ShardSelector is the callback type called by ShardPermuter.GetShard. It is invoked until false is returned, providing a backend index number for every call.