Documentation ¶
Index ¶
- Variables
- type Cluster
- type FSMSnapshot
- type Impl
- func (i *Impl) AddServer(addr string) error
- func (i *Impl) Apply(b []byte) error
- func (i *Impl) Close() error
- func (i *Impl) Get(key []byte) ([]byte, error)
- func (i *Impl) IsCandidate() bool
- func (i *Impl) IsLeader() bool
- func (i *Impl) Leader() string
- func (i *Impl) Peers() ([]string, error)
- func (i *Impl) Put(key, value []byte) error
- func (i *Impl) ShowDebugInfo(witch string) ([]byte, error)
- func (i *Impl) State() raft.RaftState
- func (i *Impl) UserSnapshot() error
- type IndexerType
- type Interface
- type Master
- func (m *Master) CurrentLeader(ctx context.Context, in *proto.MasterCurrentLeaderRequest) (*proto.MasterCurrentLeaderResponse, error)
- func (m *Master) Del(ctx context.Context, in *proto.MasterDelRequest) (*proto.MasterDelResponse, error)
- func (m *Master) Expire(ctx context.Context, in *proto.MasterExpireRequest) (*proto.MasterExpireResponse, error)
- func (m *Master) Get(ctx context.Context, in *proto.MasterGetRequest) (*proto.MasterGetResponse, error)
- func (m *Master) Keys(ctx context.Context, in *proto.MasterKeysRequest) (*proto.MasterKeysResponse, error)
- func (m *Master) ListenRequest()
- func (m *Master) ListenSlave()
- func (m *Master) NewRaft()
- func (m *Master) Ping(ctx context.Context, in *proto.MasterPingRequest) (*proto.MasterPingResponse, error)
- func (m *Master) ReceiveHeartbeat(ctx context.Context, in *proto.MasterHeartbeatRequest) (*proto.MasterHeartbeatResponse, error)
- func (m *Master) RegisterSlave(ctx context.Context, in *proto.MasterRegisterSlaveRequest) (*proto.MasterRegisterSlaveResponse, error)
- func (m *Master) Scan(ctx context.Context, in *proto.MasterScanRequest) (*proto.MasterScanResponse, error)
- func (m *Master) Set(ctx context.Context, in *proto.MasterSetRequest) (*proto.MasterSetResponse, error)
- func (m *Master) Shutdown(ctx context.Context, in *proto.MasterShutdownRequest) (*proto.MasterShutdownResponse, error)
- func (m *Master) StartGrpcServer()
- func (m *Master) TTL(ctx context.Context, in *proto.MasterTTLRequest) (*proto.MasterTTLResponse, error)
- func (m *Master) WaitForLeader()
- type Slave
- func (s *Slave) Del(ctx context.Context, in *proto.SlaveDelRequest) (*proto.SlaveDelResponse, error)
- func (s *Slave) Exists(ctx context.Context, in *proto.SlaveExistsRequest) (*proto.SlaveExistsResponse, error)
- func (s *Slave) Expire(ctx context.Context, in *proto.SlaveExpireRequest) (*proto.SlaveExpireResponse, error)
- func (s *Slave) Get(ctx context.Context, in *proto.SlaveGetRequest) (*proto.SlaveGetResponse, error)
- func (s *Slave) Heartbeat(ctx context.Context, in *proto.SlaveHeartbeatRequest) (*proto.SlaveHeartbeatResponse, error)
- func (s *Slave) Keys(ctx context.Context, in *proto.SlaveKeysRequest) (*proto.SlaveKeysResponse, error)
- func (s *Slave) ListenLeader()
- func (s *Slave) RegisterToMaster()
- func (s *Slave) SendHeartbeat()
- func (s *Slave) Set(ctx context.Context, in *proto.SlaveSetRequest) (*proto.SlaveSetResponse, error)
- func (s *Slave) StartGrpcServer()
- func (s *Slave) TTL(ctx context.Context, in *proto.SlaveTTLRequest) (*proto.SlaveTTLResponse, error)
- func (s *Slave) UpdateSlaveMessage()
- type SlaveMessage
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultOptions = config.Options{ DirPath: DefaultDbDir, DataFileSize: 256 * 1024 * 1024, SyncWrite: false, IndexType: Btree, FIOType: config.MmapIOType, }
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { //Master List Master []Master //Slave List Slave []Slave //Master List Leader Leader string }
Cluster define the cluster of db
func NewRaftCluster ¶
NewRaftCluster create a new raft db cluster
type FSMSnapshot ¶
type FSMSnapshot struct { }
FSMSnapshot use to store the snapshot of the FSM
func (*FSMSnapshot) Persist ¶
func (F *FSMSnapshot) Persist(sink raft.SnapshotSink) error
func (*FSMSnapshot) Release ¶
func (F *FSMSnapshot) Release()
type Impl ¶
type Impl struct {
// contains filtered or unexported fields
}
Impl is the interface that must be implemented by a raft server.
func (*Impl) IsCandidate ¶
func (*Impl) UserSnapshot ¶
type IndexerType ¶
type IndexerType = int8
const ( DefaultDbDir = "/tmp/flydb" Btree IndexerType = iota + 1 )
type Interface ¶
type Interface interface { State() raft.RaftState Peers() ([]string, error) Close() error IsLeader() bool IsCandidate() bool Leader() string Apply(b []byte) error AddServer(addr string) error ShowDebugInfo(witch string) ([]byte, error) UserSnapshot() error Put(key, value []byte) error Get(key []byte) ([]byte, error) }
Interface is the interface that must be implemented by a raft server.
type Master ¶
type Master struct { //grpc server proto.MasterGrpcServiceServer //ID ID string //Addr Addr string //Master List Peers []string //Slave List Slave []Slave //Heartbeat Heartbeat map[string]time.Time //Filename to node,key is filename,value is node FilenameToNode map[string]string //Dir Tree DirTree *dirtree.DirTree //Raft Raft raft.Raft //Raft Log RaftLog *boltdb.BoltStore // contains filtered or unexported fields }
func (*Master) CurrentLeader ¶
func (m *Master) CurrentLeader(ctx context.Context, in *proto.MasterCurrentLeaderRequest) (*proto.MasterCurrentLeaderResponse, error)
func (*Master) Del ¶
func (m *Master) Del(ctx context.Context, in *proto.MasterDelRequest) (*proto.MasterDelResponse, error)
func (*Master) Expire ¶
func (m *Master) Expire(ctx context.Context, in *proto.MasterExpireRequest) (*proto.MasterExpireResponse, error)
func (*Master) Get ¶
func (m *Master) Get(ctx context.Context, in *proto.MasterGetRequest) (*proto.MasterGetResponse, error)
func (*Master) Keys ¶
func (m *Master) Keys(ctx context.Context, in *proto.MasterKeysRequest) (*proto.MasterKeysResponse, error)
func (*Master) ListenRequest ¶
func (m *Master) ListenRequest()
func (*Master) ListenSlave ¶
func (m *Master) ListenSlave()
func (*Master) Ping ¶
func (m *Master) Ping(ctx context.Context, in *proto.MasterPingRequest) (*proto.MasterPingResponse, error)
func (*Master) ReceiveHeartbeat ¶
func (m *Master) ReceiveHeartbeat(ctx context.Context, in *proto.MasterHeartbeatRequest) (*proto.MasterHeartbeatResponse, error)
func (*Master) RegisterSlave ¶
func (m *Master) RegisterSlave(ctx context.Context, in *proto.MasterRegisterSlaveRequest) (*proto.MasterRegisterSlaveResponse, error)
func (*Master) Scan ¶
func (m *Master) Scan(ctx context.Context, in *proto.MasterScanRequest) (*proto.MasterScanResponse, error)
func (*Master) Set ¶
func (m *Master) Set(ctx context.Context, in *proto.MasterSetRequest) (*proto.MasterSetResponse, error)
func (*Master) Shutdown ¶
func (m *Master) Shutdown(ctx context.Context, in *proto.MasterShutdownRequest) (*proto.MasterShutdownResponse, error)
func (*Master) StartGrpcServer ¶
func (m *Master) StartGrpcServer()
func (*Master) TTL ¶
func (m *Master) TTL(ctx context.Context, in *proto.MasterTTLRequest) (*proto.MasterTTLResponse, error)
func (*Master) WaitForLeader ¶
func (m *Master) WaitForLeader()
type Slave ¶
type Slave struct { //grpc server proto.SlaveGrpcServiceServer //ID ID string //Addr Addr string //Master List Leader Leader string //Slave List Peers []string //DB DB *engine.DB //Slave Message SlaveMessage SlaveMessage //work pool WorkPool chan struct{} }
func (*Slave) Del ¶
func (s *Slave) Del(ctx context.Context, in *proto.SlaveDelRequest) (*proto.SlaveDelResponse, error)
func (*Slave) Exists ¶
func (s *Slave) Exists(ctx context.Context, in *proto.SlaveExistsRequest) (*proto.SlaveExistsResponse, error)
func (*Slave) Expire ¶
func (s *Slave) Expire(ctx context.Context, in *proto.SlaveExpireRequest) (*proto.SlaveExpireResponse, error)
func (*Slave) Get ¶
func (s *Slave) Get(ctx context.Context, in *proto.SlaveGetRequest) (*proto.SlaveGetResponse, error)
func (*Slave) Heartbeat ¶
func (s *Slave) Heartbeat(ctx context.Context, in *proto.SlaveHeartbeatRequest) (*proto.SlaveHeartbeatResponse, error)
func (*Slave) Keys ¶
func (s *Slave) Keys(ctx context.Context, in *proto.SlaveKeysRequest) (*proto.SlaveKeysResponse, error)
func (*Slave) ListenLeader ¶
func (s *Slave) ListenLeader()
func (*Slave) RegisterToMaster ¶
func (s *Slave) RegisterToMaster()
func (*Slave) SendHeartbeat ¶
func (s *Slave) SendHeartbeat()
func (*Slave) Set ¶
func (s *Slave) Set(ctx context.Context, in *proto.SlaveSetRequest) (*proto.SlaveSetResponse, error)
func (*Slave) StartGrpcServer ¶
func (s *Slave) StartGrpcServer()
func (*Slave) TTL ¶
func (s *Slave) TTL(ctx context.Context, in *proto.SlaveTTLRequest) (*proto.SlaveTTLResponse, error)
func (*Slave) UpdateSlaveMessage ¶
func (s *Slave) UpdateSlaveMessage()
Click to show internal directories.
Click to hide internal directories.