util

package
v0.0.0-...-2aa8555 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectQueue = ObjectType(iota)
	ObjectHashMap
	ObjectPubsub

	ObjectEncodeLen   = 17
	ObjectEncodeIdLen = 16
)

Variables

View Source
var (
	ErrNotFound = kv.ErrNotExist

	ErrInvalidKey = errors.New("invalid key")
	ErrInvalid    = errors.New("invalid argument")
	ErrEmpty      = errors.New("empty")
)

Functions

func DataKey

func DataKey(namespace, name []byte) []byte

{namespace}:D:{name}

func EncodeObject

func EncodeObject(obj *Object) []byte

func EncodePubsubMeta

func EncodePubsubMeta(meta *PubsubMeta) []byte

EncodePubsubMeta encode the meta of a pubsub

func EscapeKey

func EscapeKey(key string) []byte

func Int64FromBytes

func Int64FromBytes(data []byte) int64

func Int64ToBytes

func Int64ToBytes(val int64) []byte

func IsErrEmpty

func IsErrEmpty(err error) bool

func IsErrNotFound

func IsErrNotFound(err error) bool

func MetaKey

func MetaKey(namespace, name []byte) []byte

{namesapce}:M:{name}

func Unescape

func Unescape(key []byte) (string, error)

Types

type Data

type Data []byte

Data the queue of data

type GC

type GC struct {
	SysGC  *conf.GC
	TikvGC *conf.TikvGC
	// contains filtered or unexported fields
}

func NewGC

func NewGC(store kv.Storage, sconf *conf.GC, tconf *conf.TikvGC) *GC

type HashMap

type HashMap interface {
	Get(key string) ([]byte, error)
	Delete(key string) error
	Destroy() error
	Exists() bool
	GetAll() (map[string][]byte, error)
	Set(key string, val []byte) error
}

func NewHashMap

func NewHashMap(txn kv.Transaction, ns, name, usage string, useMeta bool) (HashMap, error)

type KvMeta

type KvMeta struct {
	Value map[string][]byte
	// contains filtered or unexported fields
}

type Object

type Object struct {
	ID   []byte
	Type ObjectType
}

func DecodeObject

func DecodeObject(b []byte) (obj *Object, err error)

func NewObject

func NewObject(ty ObjectType) *Object

type ObjectType

type ObjectType byte

type Pubsub

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

Pubsub is the meta of a pubsub

func NewPubsub

func NewPubsub(txn kv.Transaction, ns, name, usage string) (*Pubsub, error)

NewPubsub creates a pubsub, if the pubsub has existed, return it

func (*Pubsub) Append

func (pubs *Pubsub) Append(datas []Data) ([][]byte, error)

Append write a piece of data

func (*Pubsub) DeleteIndex

func (pubs *Pubsub) DeleteIndex(offset []byte) error

DeleteIndex delete pubsub index

func (*Pubsub) Drop

func (pubs *Pubsub) Drop() error

Drop pubsub information

func (*Pubsub) Get

func (pubs *Pubsub) Get(pos []byte) (Data, error)

func (*Pubsub) Scan

func (pubs *Pubsub) Scan(offset []byte, handler ScanHandler) error

Scan seeks to the offset and calls handler for each message if offset is null ,scan location from the first record

type PubsubMeta

type PubsubMeta struct {
	*Object
}

PubsubMeta is the meta of a pubsub

func DecodePubsubMeta

func DecodePubsubMeta(b []byte) (*PubsubMeta, error)

DecodePubsubMeta decode the meta of a pubsub

func NewPubsubMeta

func NewPubsubMeta() *PubsubMeta

NewPubsubMeta creates of the meta of a pubsub

type ScanHandler

type ScanHandler func(offset *incr_uuid.Offset, data Data) (bool, error)

ScanHandler is a handler to process scanned messages

type SysGC

type SysGC struct {
	BatchLimit     int64
	Enable         bool
	Interval       time.Duration
	LeaderLifeTime time.Duration
}

type TikvGC

type TikvGC struct {
	Enable            bool
	Interval          time.Duration
	LeaderLifeTime    time.Duration
	SafePointLifeTime time.Duration
	Concurrency       int
}

Jump to

Keyboard shortcuts

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