internal

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexIndexName        = "_meta_"
	IndexKeyPrefix        = "_idx_"
	ClusterStateIndexName = "_state_"
	ClusterStateKeyPrefix = "_cst_"
)

Variables

View Source
var Logger *log.Logger

Functions

func ReversedBucket

func ReversedBucket() []string

func ReversedIndexName

func ReversedIndexName() []string

Types

type Action

type Action int
const (
	Set Action = iota
	Del
	Get
	Search
	UpsertIndex
	DropIndex
	Ping
	Pong
	Sync
	Response
)

func (Action) Desc

func (a Action) Desc() string

type Command

type Command struct {
	Seq     string        `json:"s,omitempty"`
	Action  Action        `json:"a,omitempty"`
	Key     string        `json:"k,omitempty"`
	Value   string        `json:"v,omitempty"`
	TTL     time.Duration `json:"t,omitempty"`
	Err     string        `json:"e,omitempty"`
	Node    string        `json:"n,omitempty"`
	HasMore bool          `json:"h,omitempty"`
}

func (Command) Desc

func (cmd Command) Desc() string

func (Command) IsSync added in v0.1.1

func (cmd Command) IsSync() bool

func (Command) Validate

func (cmd Command) Validate() error

type Coordinator

func NewCoordinate

func NewCoordinate(cfg *memberlist.Config, meta Meta) (*Coordinator, error)

func (*Coordinator) Leader

func (coordinator *Coordinator) Leader() *memberlist.Node

func (*Coordinator) Nodes

func (coordinator *Coordinator) Nodes() []string

func (*Coordinator) NotifyJoin

func (coordinator *Coordinator) NotifyJoin(node *memberlist.Node)

func (*Coordinator) NotifyLeave

func (coordinator *Coordinator) NotifyLeave(node *memberlist.Node)

func (*Coordinator) NotifyMerge

func (coordinator *Coordinator) NotifyMerge(peers []*memberlist.Node) error

func (*Coordinator) NotifyUpdate

func (coordinator *Coordinator) NotifyUpdate(node *memberlist.Node)

func (*Coordinator) Version

func (coordinator *Coordinator) Version() string

type Hash

type Hash struct{}

func (Hash) Sum64

func (h Hash) Sum64(bytes []byte) uint64

type Hook

type Hook func() error

type Meta

type Meta struct {
	Replicas    int           `json:"replicas"`
	Timeout     time.Duration `json:"timeout"`
	Retry       int           `json:"retry"`
	Partitions  int           `json:"partitions"`
	Role        Role          `json:"role"`
	StartedAt   string        `json:"startedAt"`
	GossipNodes int           `json:"gossipNodes"`
}

type Role

type Role int
const (
	DataNode Role = iota
	Follower
)

type SearchHook added in v0.1.2

type SearchHook func(k, v string) (bool, error)

type Storage

type Storage struct {
	*buntdb.DB
}

func NewStorage

func NewStorage() (*Storage, error)

func (*Storage) BatchDel

func (s *Storage) BatchDel(rows []Row) error

func (*Storage) BatchSet

func (s *Storage) BatchSet(rows []Row, hook Hook) error

func (*Storage) CountIndex added in v0.1.2

func (s *Storage) CountIndex(index string, predicate SearchHook) int

func (*Storage) Del

func (s *Storage) Del(key string) error

func (*Storage) Get

func (s *Storage) Get(k string) (v string, ttl time.Duration, err error)

func (*Storage) Indexes

func (s *Storage) Indexes() []VersionedIndex

func (*Storage) Persist

func (s *Storage) Persist(cmd Command, hook Hook) error

func (*Storage) ScanIndex

func (s *Storage) ScanIndex(index string, predicate SearchHook) []Row

func (*Storage) ScanIndexStream

func (s *Storage) ScanIndexStream(index string, criteria *Criteria, ch chan<- Row, predicate SearchHook)

func (*Storage) Set

func (s *Storage) Set(k, v string, ttl time.Duration, hook Hook) error

func (*Storage) Ttl

func (s *Storage) Ttl(k string) (time.Duration, error)

type VersionedIndex added in v0.1.2

type VersionedIndex struct {
	Index
	Version string
}

Jump to

Keyboard shortcuts

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