sharding

package
v0.0.0-...-a9d0937 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewShardingBlobAccess

func NewShardingBlobAccess(backends []blobstore.BlobAccess, shardPermuter ShardPermuter, 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

type ShardSelector func(int) bool

ShardSelector is the callback type called by ShardPermuter.GetShard. It is invoked until false is returned, providing a backend index number for every call.

Jump to

Keyboard shortcuts

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