node

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

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventPut = 1 << iota
	EventDel
)

Variables

This section is empty.

Functions

func EncodeDel

func EncodeDel(key string) []byte

func EncodePut

func EncodePut(key string, value []byte) []byte

Types

type KVNode

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

func NewKVNode

func NewKVNode(kv kv.KV, opts ...NodeOption) *KVNode

func (*KVNode) AddNode

func (nd *KVNode) AddNode(serverID, bind string, prevIndex uint64)

Can only the leader do this

func (*KVNode) Apply

func (nd *KVNode) Apply(l *raft.Log) interface{}

func (*KVNode) Del

func (nd *KVNode) Del(key string) error

func (*KVNode) Get

func (nd *KVNode) Get(key string, level rpc.ReadLevel) ([]byte, error)

func (*KVNode) GetMeta

func (nd *KVNode) GetMeta() ([]kv.ServerConfig, error)

func (*KVNode) Put

func (nd *KVNode) Put(key string, value []byte) error

func (*KVNode) RemoveNode

func (nd *KVNode) RemoveNode(serverID, bind string, prevIndex uint64)

Can only the leader do this

func (*KVNode) Restore

func (nd *KVNode) Restore(snapshot io.ReadCloser) error

func (*KVNode) Shutdown

func (nd *KVNode) Shutdown()

func (*KVNode) Snapshot

func (nd *KVNode) Snapshot() (raft.FSMSnapshot, error)

func (*KVNode) WaitApplied

func (nd *KVNode) WaitApplied(timeout time.Duration) error

func (*KVNode) WaitForLeader

func (nd *KVNode) WaitForLeader(timeout time.Duration) error

type LogEvent

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

func DecodeLogEvent

func DecodeLogEvent(in []byte) *LogEvent

func (*LogEvent) Encode

func (e *LogEvent) Encode() []byte

type NodeOption

type NodeOption func(kv *KVNode)

func WithBind

func WithBind(bind string) NodeOption

func WithBootstrap

func WithBootstrap(b bool) NodeOption

func WithBootstrapAddress

func WithBootstrapAddress(addr string) NodeOption

func WithDebug

func WithDebug(b bool) NodeOption

func WithID

func WithID(id string) NodeOption

func WithRpcAddress

func WithRpcAddress(addr string) NodeOption

func WithStorageRoot

func WithStorageRoot(path string) NodeOption

type SKVServerImpl

type SKVServerImpl struct {
	rpc.UnimplementedSKVServer
	rpc.UnimplementedPeerServer
	// contains filtered or unexported fields
}

func NewSKVServer

func NewSKVServer(opts []kv.KVOption, ndopts []NodeOption) *SKVServerImpl

func (*SKVServerImpl) Del

func (skv *SKVServerImpl) Del(ctx context.Context, req *rpc.DelRequest) (*rpc.DelReply, error)

func (*SKVServerImpl) Get

func (skv *SKVServerImpl) Get(ctx context.Context, req *rpc.GetRequest) (*rpc.GetReply, error)

func (*SKVServerImpl) GetMeta

func (skv *SKVServerImpl) GetMeta(ctx context.Context, req *rpc.GetMetaRequest) (*rpc.GetMetaReply, error)

func (*SKVServerImpl) Join

func (skv *SKVServerImpl) Join(ctx context.Context, req *rpc.PeerRequest) (*rpc.PeerReply, error)

func (*SKVServerImpl) Put

func (skv *SKVServerImpl) Put(ctx context.Context, req *rpc.KeyValuePair) (*rpc.PutReply, error)

func (*SKVServerImpl) Quit

func (skv *SKVServerImpl) Quit(ctx context.Context, req *rpc.PeerRequest) (*rpc.PeerReply, error)

func (*SKVServerImpl) Scan

func (skv *SKVServerImpl) Scan(opts *rpc.ScanOption, stream rpc.SKV_ScanServer) error

func (*SKVServerImpl) Shutdown

func (skv *SKVServerImpl) Shutdown()

type SKVSnapshot

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

func (*SKVSnapshot) Persist

func (ss *SKVSnapshot) Persist(sink raft.SnapshotSink) error

func (*SKVSnapshot) Release

func (ss *SKVSnapshot) Release()

Jump to

Keyboard shortcuts

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