sharded

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHashed

func NewHashed(shards uint32, factory StorageFactoryFunc) *hashShard

New shard pool based on default hash distribution IEEE CRC-32. See HashedCustom for details.

Example
pool := NewHashed(3, func(shardID uint32) (storages.Storage, error) {
	return nil, errors.New("TODO: any storage implementation")
})

shardedStorage := storages.Sharded(pool)
defer shardedStorage.Close()
// do something
Output:

func NewHashedArray

func NewHashedArray(shards []storages.Storage) *hashShard

New pool based on default hash distribution and fixed number of pre-allocated shards

func NewHashedCustom

func NewHashedCustom(shards uint32, factory StorageFactoryFunc, hashFunc HashShardFunc) *hashShard

New shard pool based on custom hash distribution. Shards will be open dynamically on-demand and kept open till pool closed. Thread safe.

Types

type HashShardFunc

type HashShardFunc func([]byte) uint32

Hash function of key to determinate shard id. Non-scaled

type StorageFactoryFunc

type StorageFactoryFunc func(shardID uint32) (storages.Storage, error)

Factory function to create storage by id (id scaled in range of defined shard number)

Jump to

Keyboard shortcuts

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