Documentation
¶
Index ¶
- type Cluster
- type Command
- type Dispatcher
- func (d *Dispatcher) AddMember(id uint64, addr string) error
- func (d *Dispatcher) AddPolicies(sec string, ptype string, rules [][]string) error
- func (d *Dispatcher) ClearPolicy() error
- func (d *Dispatcher) EnableTLSTransport(keyFile string, certFile string, caFile string)
- func (d *Dispatcher) IsIDRemoved(id uint64) bool
- func (d *Dispatcher) Process(ctx context.Context, m raftpb.Message) error
- func (d *Dispatcher) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (d *Dispatcher) RemoveMember(id uint64) error
- func (d *Dispatcher) RemovePolicies(sec string, ptype string, rules [][]string) error
- func (d *Dispatcher) ReportSnapshot(id uint64, status raft.SnapshotStatus)
- func (d *Dispatcher) ReportUnreachable(id uint64)
- func (d *Dispatcher) Restart() error
- func (d *Dispatcher) SetElectionTick(num int)
- func (d *Dispatcher) SetEnforcer(enforcer interface{}) error
- func (d *Dispatcher) SetHeartbeatTick(num int)
- func (d *Dispatcher) SetSnapDirName(name string)
- func (d *Dispatcher) SetSnapshotCount(count uint64)
- func (d *Dispatcher) SetWalDirName(name string)
- func (d *Dispatcher) Start() error
- func (d *Dispatcher) Stop()
- type Engine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster manage the node id and url
func NewCluster ¶
NewCluster create a Cluster frome map
func (*Cluster) ApplyConfigChange ¶
func (c *Cluster) ApplyConfigChange(cc raftpb.ConfChange)
ApplyConfigChange apply the Ready ConfChange Message
func (*Cluster) RemoveMember ¶
RemoveMember remove a existed member from Cluster
type Command ¶
type Command struct { Op int `json:"op"` Sec string `json:"sec"` Ptype string `json:"ptype"` Rules [][]string `json:"rules"` FiledIndex int `json:"filed_index"` FiledValues []string `json:"filed_values"` }
Command represents an instruction to change the state of the engine
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is a casbin enforcer backed by raft
func NewDispatcher ¶
func NewDispatcher(id uint64, peers map[uint64]string, join ...bool) *Dispatcher
NewDispatcher return a instance of dispatcher, the peers is a collection of id and url of all nodes in the cluster
func (*Dispatcher) AddMember ¶
func (d *Dispatcher) AddMember(id uint64, addr string) error
AddMember add a new node to Cluster.
func (*Dispatcher) AddPolicies ¶
func (d *Dispatcher) AddPolicies(sec string, ptype string, rules [][]string) error
AddPolicies add policies to casbin enforcer This function will be call by casbin. Please call casbin ManagementAPI for use.
func (*Dispatcher) ClearPolicy ¶
func (d *Dispatcher) ClearPolicy() error
ClearPolicy clears all policy. This function will be call by casbin. Please call casbin ManagementAPI for use.
func (*Dispatcher) EnableTLSTransport ¶
func (d *Dispatcher) EnableTLSTransport(keyFile string, certFile string, caFile string)
EnableTLSTransport make transport protected by TLS. This function must be called before call node.Start().
func (*Dispatcher) IsIDRemoved ¶
func (d *Dispatcher) IsIDRemoved(id uint64) bool
func (*Dispatcher) RemoveFilteredPolicy ¶
func (d *Dispatcher) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy removes a role inheritance rule from the current named policy, field filters can be specified. This function will be call by casbin. Please call casbin ManagementAPI for use.
func (*Dispatcher) RemoveMember ¶
func (d *Dispatcher) RemoveMember(id uint64) error
RemoveMember remove a exist Node from Cluster.
func (*Dispatcher) RemovePolicies ¶
func (d *Dispatcher) RemovePolicies(sec string, ptype string, rules [][]string) error
RemovePolicies remove policies from casbin enforcer This function will be call by casbin. Please call casbin ManagementAPI for use.
func (*Dispatcher) ReportSnapshot ¶
func (d *Dispatcher) ReportSnapshot(id uint64, status raft.SnapshotStatus)
func (*Dispatcher) ReportUnreachable ¶
func (d *Dispatcher) ReportUnreachable(id uint64)
func (*Dispatcher) Restart ¶
func (d *Dispatcher) Restart() error
Restart init raft from wal and snapshot that already existing, then begin serving requests
func (*Dispatcher) SetElectionTick ¶
func (d *Dispatcher) SetElectionTick(num int)
SetElectionTick set the number of Node.Tick invocations that must pass between elections. ElectionTick must be greater than HeartbeatTick. We suggest ElectionTick = 10 * HeartbeatTick to avoid unnecessary leader switching. This function must be called before call node.Start().
func (*Dispatcher) SetEnforcer ¶
func (d *Dispatcher) SetEnforcer(enforcer interface{}) error
SetEnforcer set up the instance that need to be maintained. The parameter should be SyncedEnforced
func (*Dispatcher) SetHeartbeatTick ¶
func (d *Dispatcher) SetHeartbeatTick(num int)
SetHeartbeatTick set the number of Node.Tick invocations that must pass between heartbeats. That is, a leader sends heartbeat messages to maintain its leadership every HeartbeatTick ticks. This function must be called before call node.Start().
func (*Dispatcher) SetSnapDirName ¶
func (d *Dispatcher) SetSnapDirName(name string)
SetSnapDirName set the directory name that store sanpshot file. This function must be called before call node.Start().
func (*Dispatcher) SetSnapshotCount ¶
func (d *Dispatcher) SetSnapshotCount(count uint64)
SetSnapshotCount set the number of logs that trigger a snapshot save. This function must be called before call node.Start().
func (*Dispatcher) SetWalDirName ¶
func (d *Dispatcher) SetWalDirName(name string)
SetWalDirName set the directory name that store write ahead log file. This function must be called before call node.Start().
func (*Dispatcher) Start ¶
func (d *Dispatcher) Start() error
Start performs any initialization of the Server necessary for it to begin serving requests.