Documentation ¶
Index ¶
- Constants
- Variables
- type Commend
- func (*Commend) Descriptor() ([]byte, []int)deprecated
- func (x *Commend) GetBody() []byte
- func (x *Commend) GetCmd() string
- func (x *Commend) GetNamespace() string
- func (*Commend) ProtoMessage()
- func (x *Commend) ProtoReflect() protoreflect.Message
- func (x *Commend) Reset()
- func (x *Commend) String() string
- type ICommitEventHandler
- type ICreateHandler
- type IRaftEventHandler
- type IRaftServiceHandler
- type IService
- type Service
- func (s *Service) AddCommitEventHandler(h ICommitEventHandler)
- func (s *Service) AddEventHandler(h IRaftEventHandler)
- func (s *Service) Append(cmd string, data []byte) error
- func (s *Service) Commit(data []byte) error
- func (s *Service) CommitHandler(cmd string, data []byte) error
- func (s *Service) Complete() error
- func (s *Service) GetInit() ([]byte, error)
- func (s *Service) GetSnapshot() ([]byte, error)
- func (s *Service) PreProcessData(inBody []byte) (object interface{}, data []byte, err error)
- func (s *Service) ProcessHandler(cmd string, body []byte) ([]byte, interface{}, error)
- func (s *Service) ResetHandler(data []byte) error
- func (s *Service) ResetSnap(data []byte) error
- func (s *Service) Send(namespace, cmd string, body []byte) (interface{}, error)
- func (s *Service) SetHandler(namespace string, handler IRaftServiceHandler)
- func (s *Service) SetHandlers(handlers ...ICreateHandler)
- func (s *Service) SetRaft(raft raft.IRaftSender)
- func (s *Service) Snapshot() []byte
Constants ¶
View Source
const ( CommandInit = "init" SystemNamespace = "__system" EventReset = "reset" EventComplete = "complete" )
Variables ¶
View Source
var ( ErrInvalidNamespace = errors.New("invalid namespace") ErrInvalidCommitHandler = errors.New("invalid commit handler") ErrInvalidCommand = errors.New("invalid command") )
View Source
var File_msg_proto protoreflect.FileDescriptor
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) GetNamespace ¶ added in v0.1.0
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
type ICommitEventHandler ¶ added in v0.3.0
type ICommitEventHandler func(namespace, cmd 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 IRaftEventHandler ¶ added in v0.3.0
type IRaftEventHandler func(event string)
type IRaftServiceHandler ¶ added in v0.1.0
type IRaftServiceHandler interface { // ResetHandler 初始化snapshot ResetHandler(data []byte) error // Append 追加需要初始化的日志 Append(cmd string, data []byte) error // Complete 初始化完成 Complete() error // CommitHandler 节点commit信息前的处理 CommitHandler(cmd string, data []byte) error // Snapshot 获取快照 Snapshot() []byte // ProcessHandler leader 节点propose信息前的处理 ProcessHandler(cmd string, body []byte) ([]byte, interface{}, error) }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService() *Service
func (*Service) AddCommitEventHandler ¶ added in v0.3.0
func (s *Service) AddCommitEventHandler(h ICommitEventHandler)
func (*Service) AddEventHandler ¶ added in v0.3.0
func (s *Service) AddEventHandler(h IRaftEventHandler)
func (*Service) GetSnapshot ¶
func (*Service) PreProcessData ¶ added in v0.3.0
func (*Service) ProcessHandler ¶
func (*Service) ResetHandler ¶ added in v0.3.0
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)
Click to show internal directories.
Click to hide internal directories.