raft_service

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidNamespace     = errors.New("invalid namespace")
	ErrInvalidCommitHandler = errors.New("invalid commit handler")
	ErrInvalidKey           = errors.New("invalid key")
)

Functions

func RegisterWorker

func RegisterWorker(s *Service)

Types

type ICommitHandler

type ICommitHandler interface {
	// InitHandler 初始化日志操作
	ResetHandler(data []byte) error
	// CommitHandler 节点commit信息前的处理
	CommitHandler(data []byte) error

	Snapshot() []byte
}

type IProcessHandler

type IProcessHandler interface {
	// ProcessHandler 节点propose信息前的处理
	ProcessHandler(propose []byte) (string, []byte, error)
}

type KV

type KV struct {
	Key    string
	Config interface{}
}

KV 用于传输的结构

func (*KV) Decode

func (kv *KV) Decode(data []byte) error

func (*KV) Encode

func (kv *KV) Encode() ([]byte, error)

type Profession

type Profession struct {
}

func (*Profession) CommitHandler

func (p *Profession) CommitHandler(data []byte) error

func (*Profession) ProcessHandler

func (p *Profession) ProcessHandler(propose []byte) (string, []byte, error)

type Service

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

func NewService

func NewService(store eosc.IStore) *Service

func (*Service) CommitHandler

func (s *Service) CommitHandler(namespace string, data []byte) error

func (*Service) CommitHandlerSet

func (s *Service) CommitHandlerSet(namespace string, handler ICommitHandler)

func (*Service) GetInit

func (s *Service) GetInit() (string, []byte, error)

func (*Service) GetSnapshot

func (s *Service) GetSnapshot() ([]byte, error)

func (*Service) ProcessHandler

func (s *Service) ProcessHandler(namespace string, propose []byte) (string, []byte, error)

func (*Service) ProcessHandlerSet

func (s *Service) ProcessHandlerSet(namespace string, handler IProcessHandler)

func (*Service) ResetSnap

func (s *Service) ResetSnap(data []byte) error

type Worker

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

func NewWorker

func NewWorker(store eosc.IStore) *Worker

func (*Worker) CommitHandler

func (w *Worker) CommitHandler(data []byte) error

func (*Worker) ProcessHandler

func (w *Worker) ProcessHandler(propose []byte) (string, []byte, error)

func (*Worker) ResetHandler

func (w *Worker) ResetHandler(data []byte) error

func (*Worker) Snapshot

func (w *Worker) Snapshot() []byte

type WorkerCmd

type WorkerCmd struct {
	Key    string
	Config *baseConfig
}

WorkerCmd 用于传输的结构

func (*WorkerCmd) Decode

func (kv *WorkerCmd) Decode(data []byte) error

func (*WorkerCmd) Encode

func (kv *WorkerCmd) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

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