common

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2017 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxUint   = ^uint64(0)
	ZeroPoint = MaxUint / 1000000000
)

Constanst to correctly converts uint64 sequences to int

Variables

View Source
var (
	ElementsBucket = []byte("_elements")
	IDToSeqBucket  = []byte("_id2seq")
	SeqToIDBucket  = []byte("_seq2id")
	StatBytes      = []byte("_stat")
)

common sub buckets names

View Source
var (
	ErrNotFound         = errors.New("not found")
	ErrSeqToIDBucket    = errors.New("seqToIDBucket is not exists")
	ErrExists           = errors.New("element exists")
	ErrNoIDInTheElement = errors.New("no id in element")
)

common errors

Functions

func BytesToSeq

func BytesToSeq(b []byte) (seq uint64)

BytesToSeq converts []byte implementation of sequence to uint64

func ExtractID

func ExtractID(data interface{}) (string, bool)

ExtractID returns _id property of the passed interface{} if it is a map[string]interface{}

func GetEncodedSeqByID

func GetEncodedSeqByID(queue string, id []byte, b *bolt.Bucket) ([]byte, error)

GetEncodedSeqByID returns []byte representation of the item sequence key by item _id property

func IntToUint

func IntToUint(i int) uint64

IntToUint adds ZeroPoint offset to int input argument and convert value to uint64

func SeqToBytes

func SeqToBytes(seq uint64) []byte

SeqToBytes converts uint64 implementation of sequence to []byte

func SetSeqToIDRef

func SetSeqToIDRef(seq, id []byte, b *bolt.Bucket) error

SetSeqToIDRef creates index records when key is a sequence and value is a item _id

func UintToInt

func UintToInt(u uint64) int

UintToInt subtract ZeroPoint offset from uint64 input argument and convert value to int

Types

This section is empty.

Jump to

Keyboard shortcuts

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