kvstore

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWatcherStopped = errors.New("watcher is stopped")
	ErrNotImplement   = errors.New("the method is not implement")
)

Functions

func Variadic added in v0.3.12

func Variadic(opts ...Option) variadic

Types

type Event

type Event interface {
	Len() int
	Key(i int) string
	Value(i int) []byte
	Type(i int) Type // PUT, DELETE
}

type KV

type KV interface {
	Set(ctx context.Context, key string, val []byte, opts ...Option) error
	Get(ctx context.Context, key string, opts ...Option) (Result, error)
	Del(ctx context.Context, key string, opts ...Option) error
	Watch(ctx context.Context, opts ...Option) Watcher
	Close() error
	String() string
}

KV is the source from which config is loaded.

type KeepAliveCallback added in v0.3.12

type KeepAliveCallback func(id, ttl int64, cancel func())

type Option

type Option func(Param) Param

func Count added in v0.3.12

func Count() Option

get num of key-value pairs

func FromKey added in v0.3.12

func FromKey() Option

分页查询开始key, 如果为空则从第一个开始 nextKey = $(lastKey) + "\x00", 在 etcd 中,键是按字典序排序的。通过追加 \x00,可以确保下一个键是当前键的后一个键

func IgnoreLease added in v0.3.12

func IgnoreLease() Option

ignore expired keys

func KeepAlive added in v0.3.12

func KeepAlive(f KeepAliveCallback) Option

func KeyOnly added in v0.3.12

func KeyOnly() Option

func Limit added in v0.3.12

func Limit(val uint32) Option

set the batch size of get

func MatchPrefix added in v0.3.12

func MatchPrefix() Option

func TTL added in v0.3.12

func TTL(val uint32) Option

type Param added in v0.3.12

type Param interface {
	Value(key any) any
}

func WithValue added in v0.3.12

func WithValue(parent Param, key, val any) Param

type Result added in v0.3.12

type Result interface {
	Len() int
	Key(i int) string
	Value(i int) []byte
}

type Type added in v0.3.12

type Type string
const (
	NONE   Type = "NONE"
	PUT    Type = "PUT"
	DELETE Type = "DELETE"
)

type Watcher

type Watcher interface {
	Next(ctx context.Context) (Event, error)
	Stop() error
}

Watcher watches a source for changes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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