kvdb

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

dfuse Key/Value Store

reference License

This library contains different implementations for storing blocks and transactions in a key/value database. It is used by dfuse.

Usage

db, err := store.New(dsn)
if err != nil {
    return fmt.Errorf("failed setting up db: %s", err)
}

The following DSNs are provided by this package:

  • Badger: badger:///home/user/dfuse-data/component/my-badger.db
  • TiKV: tikv://pd0,pd1,pd2:2379?prefix=namespace_prefix
  • Google Cloud BigTable: bigkv://project.instance/namespace-prefix?createTables=true

Beware that the TiKV backend does not support 0-length values. Design your client code accordingly (like we did in FluxDB).

Contributing

Issues and PR in this repo related strictly to the kvdb library.

Report any protocol-specific issues in their respective repositories

Please first refer to the general dfuse contribution guide, if you wish to contribute to this code base.

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var B = func(s string) []byte {
	out, err := hex.DecodeString(s)
	if err != nil {
		panic(err)
	}

	return out
}

B is a shortcut for (must) hex.DecodeString

View Source
var (
	ErrNotFound = errors.New("not found")
)

H is a shortcut for hex.EncodeToString

Functions

func BlockNum

func BlockNum(blockID string) uint32

func BoolToByte

func BoolToByte(value bool) byte

func ByteToBool

func ByteToBool(value []byte) bool

func FromHexUint16

func FromHexUint16(input string) (uint16, error)

func FromHexUint64

func FromHexUint64(input string) (uint64, error)

func FromRevBlockNum64

func FromRevBlockNum64(input string) (uint64, error)

func HexName

func HexName(name uint64) string

func HexRevBlockNum

func HexRevBlockNum(blockNum uint32) string

func HexRevBlockNum64

func HexRevBlockNum64(blockNum uint64) string

func HexUint16

func HexUint16(input uint16) string

func HexUint32

func HexUint32(input uint32) string

func HexUint64

func HexUint64(input uint64) string

func IncreaseBlockIDSuffix

func IncreaseBlockIDSuffix(blockID string) string

increaseBlockIDSuffix increases the last bits of the blockID, to make it to the next block in an InfiniteRange search. WARN: if the last characters are: "ffffffff", then it will overflow, and return a *lower* key.

func MustProtoMarshal

func MustProtoMarshal(obj proto.Message) []byte

func ReversedBlockID

func ReversedBlockID(blockID string) string

func ReversedUint16

func ReversedUint16(input uint16) uint16

func StringListToBytes

func StringListToBytes(value []string, separator string) []byte

func Uint64ToBytes

func Uint64ToBytes(value uint64) []byte

Types

type BlockIdentifier

type BlockIdentifier string

BlockIdentifier is present only for testing purposes. This wrap a string of the format `<Num><letter>` and add block ref methods `Num` and `ID`. This way in tests, it's easy to create block identifier for example `1a` or `3c` to represents blocks num + id consicely.

func (BlockIdentifier) ID

func (i BlockIdentifier) ID() string

func (BlockIdentifier) Num

func (i BlockIdentifier) Num() (out uint64)

Directories

Path Synopsis
base

Jump to

Keyboard shortcuts

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