xidmap

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2017 License: AGPL-3.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// NumShards controls the number of shards the XidMap is broken into. More
	// shards reduces lock contention.
	NumShards int
	// LRUSize controls the total size of the LRU cache. The LRU is split
	// between all shards, so with 4 shards and an LRUSize of 100, each shard
	// receives 25 LRU slots.
	LRUSize int
}

Options controls the performance characteristics of the XidMap.

type XidMap

type XidMap struct {
	// contains filtered or unexported fields
}

XidMap allocates and tracks mappings between Xids and Uids in a threadsafe manner. It's memory friendly because the mapping is stored on disk, but fast because it uses an LRU cache.

func New

func New(kv *badger.DB, pool *ZeroPool, opt Options) *XidMap

New creates an XidMap with given badger and uid provider.

func (*XidMap) AllocateUid

func (m *XidMap) AllocateUid() uint64

AllocateUid gives a single uid without creating an xid to uid mapping.

func (*XidMap) AssignUid

func (m *XidMap) AssignUid(xid string) (uid uint64, isNew bool)

AssignUid creates new or looks up existing XID to UID mappings.

type ZeroPool added in v1.0.0

type ZeroPool struct {
	// contains filtered or unexported fields
}

func NewZeroPool added in v1.0.0

func NewZeroPool(dial func(string) (*grpc.ClientConn, error), addr string) *ZeroPool

func (*ZeroPool) Leader added in v1.0.0

func (p *ZeroPool) Leader() (intern.ZeroClient, error)

Jump to

Keyboard shortcuts

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