store

package
v0.0.0-...-4fc5882 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Factories = map[string]func(conf Conf) (DB, error){}

Factories of database

Functions

func ByteToU64

func ByteToU64(v []byte) uint64

ByteToU64 converts bytes to uint64

func U64ToByte

func U64ToByte(v uint64) []byte

U64ToByte converts uint64 to bytes

func U64U64ToByte

func U64U64ToByte(sid, ts uint64) []byte

U64U64ToByte converts two uint64 to bytes

Types

type Bucket

type Bucket interface {
	Put([]interface{}) error
	Get(offset uint64, length int, results interface{}) error
	DelBeforeID(uint64) error
	DelBeforeTS(time.Time) error

	SetKV(k string, v interface{}) error
	GetKV(k string, result interface{}) error
	DelKV(k string) error
	ListKV(results interface{}) error

	Close(clean bool) (err error)
}

Bucket the backend database

type Conf

type Conf struct {
	Driver string `yaml:"driver" json:"driver" default:"boltdb"`
	Source string `yaml:"source" json:"source" default:"var/lib/baetyl/broker.db"`
}

Conf the configuration of database

type DB

type DB interface {
	NewBucket(name string, encoder Encoder) (Bucket, error)
	io.Closer
}

func New

func New(conf Conf) (DB, error)

New DB by given name

type Encoder

type Encoder interface {
	Encode(value interface{}) (data []byte, err error)
	Decode(data []byte, value interface{}, args ...interface{}) error
}

Encoder value encode/decode interface

func NewDefaultEncoder

func NewDefaultEncoder() Encoder

Jump to

Keyboard shortcuts

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