raft_service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandInit     = "init"
	SystemNamespace = "__system"
)

Variables

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

Functions

This section is empty.

Types

type Commend added in v0.1.0

type Commend struct {
	Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
	Cmd       string `protobuf:"bytes,2,opt,name=cmd,proto3" json:"cmd,omitempty"`
	Body      []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

func (*Commend) Descriptor deprecated added in v0.1.0

func (*Commend) Descriptor() ([]byte, []int)

Deprecated: Use Commend.ProtoReflect.Descriptor instead.

func (*Commend) GetBody added in v0.1.0

func (x *Commend) GetBody() []byte

func (*Commend) GetCmd added in v0.1.0

func (x *Commend) GetCmd() string

func (*Commend) GetNamespace added in v0.1.0

func (x *Commend) GetNamespace() string

func (*Commend) ProtoMessage added in v0.1.0

func (*Commend) ProtoMessage()

func (*Commend) ProtoReflect added in v0.1.0

func (x *Commend) ProtoReflect() protoreflect.Message

func (*Commend) Reset added in v0.1.0

func (x *Commend) Reset()

func (*Commend) String added in v0.1.0

func (x *Commend) String() string

type ICreateHandler added in v0.1.0

type ICreateHandler interface {
	Namespace() string
	Handler() IRaftServiceHandler
}

func NewCreateHandler added in v0.1.0

func NewCreateHandler(namespace string, handler IRaftServiceHandler) ICreateHandler

type IRaftServiceHandler added in v0.1.0

type IRaftServiceHandler interface {
	// ResetHandler  初始化日志操作
	ResetHandler(data []byte) error
	// CommitHandler 节点commit信息前的处理
	CommitHandler(cmd string, data []byte) error
	// Snapshot 获取快照
	Snapshot() []byte
	// ProcessHandler 节点propose信息前的处理
	ProcessHandler(cmd string, body []byte) ([]byte, interface{}, error)
}

type IService added in v0.1.0

type IService interface {
	Send(namespace, cmd string, body []byte) (interface{}, error)
}

type Service

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

func NewService

func NewService() *Service

func (*Service) CommitHandler

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

func (*Service) GetInit

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

func (*Service) GetSnapshot

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

func (*Service) ProcessDataHandler added in v0.1.0

func (s *Service) ProcessDataHandler(inBody []byte) (object interface{}, data []byte, err error)

func (*Service) ProcessHandler

func (s *Service) ProcessHandler(namespace string, command string, processData []byte) (interface{}, []byte, error)

func (*Service) ResetSnap

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

func (*Service) Send added in v0.1.0

func (s *Service) Send(namespace, cmd string, body []byte) (interface{}, error)

func (*Service) SetHandler added in v0.1.0

func (s *Service) SetHandler(namespace string, handler IRaftServiceHandler)

func (*Service) SetHandlers added in v0.1.0

func (s *Service) SetHandlers(handlers ...ICreateHandler)

func (*Service) SetRaft added in v0.1.0

func (s *Service) SetRaft(raft raft.IRaftSender)

Jump to

Keyboard shortcuts

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