Documentation ¶
Index ¶
- type Config
- type FSM
- type PolicyOperator
- func (p *PolicyOperator) AddPolicies(sec, pType string, rules [][]string) error
- func (p *PolicyOperator) Backup() ([]byte, error)
- func (p *PolicyOperator) ClearPolicy() error
- func (p *PolicyOperator) LoadPolicy() error
- func (p *PolicyOperator) RemoveFilteredPolicy(sec string, pType string, fieldIndex int, fieldValues ...string) error
- func (p *PolicyOperator) RemovePolicies(sec, pType string, rules [][]string) error
- func (p *PolicyOperator) Restore(rc io.ReadCloser) error
- func (p *PolicyOperator) UpdatePolicies(sec, pType string, oldRules, newRules [][]string) error
- func (p *PolicyOperator) UpdatePolicy(sec, pType string, oldRule, newRule []string) error
- type Rule
- type Store
- func (s *Store) AddPolicies(request *command.AddPoliciesRequest) error
- func (s *Store) Address() string
- func (s *Store) ClearPolicy() error
- func (s *Store) DataDir() string
- func (s *Store) ID() string
- func (s *Store) IsInitializedCluster() bool
- func (s *Store) JoinNode(serverID string, address string) error
- func (s *Store) Leader() (bool, string)
- func (s *Store) RemoveFilteredPolicy(request *command.RemoveFilteredPolicyRequest) error
- func (s *Store) RemoveNode(serverID string) error
- func (s *Store) RemovePolicies(request *command.RemovePoliciesRequest) error
- func (s *Store) Start(enableBootstrap bool) error
- func (s *Store) Stats() (map[string]interface{}, error)
- func (s *Store) Stop() error
- func (s *Store) UpdatePolicies(request *command.UpdatePoliciesRequest) error
- func (s *Store) UpdatePolicy(request *command.UpdatePolicyRequest) error
- func (s *Store) WaitLeader() error
- type TCPStreamLayer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSM ¶
type FSM struct {
// contains filtered or unexported fields
}
FSM is state storage.
func (*FSM) Restore ¶
func (f *FSM) Restore(rc io.ReadCloser) error
Restore is used to restore an FSM from a snapshot. It is not called concurrently with any other command. The FSM must discard all previous state.
func (*FSM) Snapshot ¶
func (f *FSM) Snapshot() (raft.FSMSnapshot, error)
Snapshot is used to support log compaction. This call should return an FSMSnapshot which can be used to save a point-in-time snapshot of the FSM. Apply and Snapshot are not called in multiple threads, but Apply will be called concurrently with Persist. This means the FSM should be implemented in a fashion that allows for concurrent updates while a snapshot is happening.
type PolicyOperator ¶
type PolicyOperator struct {
// contains filtered or unexported fields
}
PolicyOperator is used to update policies and provide persistence.
func NewPolicyOperator ¶
func NewPolicyOperator(path string, e casbin.IDistributedEnforcer) (*PolicyOperator, error)
NewPolicyOperator returns a PolicyOperator.
func (*PolicyOperator) AddPolicies ¶
func (p *PolicyOperator) AddPolicies(sec, pType string, rules [][]string) error
AddPolicies adds a set of rules.
func (*PolicyOperator) Backup ¶
func (p *PolicyOperator) Backup() ([]byte, error)
Backup writes the database to bytes with gzip.
func (*PolicyOperator) ClearPolicy ¶
func (p *PolicyOperator) ClearPolicy() error
ClearPolicy clears all rules.
func (*PolicyOperator) LoadPolicy ¶
func (p *PolicyOperator) LoadPolicy() error
LoadPolicy clears the policies held by enforcer, and loads policy from database.
func (*PolicyOperator) RemoveFilteredPolicy ¶
func (p *PolicyOperator) RemoveFilteredPolicy(sec string, pType string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy removes a set of rules that match a pattern.
func (*PolicyOperator) RemovePolicies ¶
func (p *PolicyOperator) RemovePolicies(sec, pType string, rules [][]string) error
RemovePolicies removes a set of rules.
func (*PolicyOperator) Restore ¶
func (p *PolicyOperator) Restore(rc io.ReadCloser) error
Restore is used to restore a database from io.ReadCloser.
func (*PolicyOperator) UpdatePolicies ¶
func (p *PolicyOperator) UpdatePolicies(sec, pType string, oldRules, newRules [][]string) error
UpdatePolicies replaces a set of existing rule.
func (*PolicyOperator) UpdatePolicy ¶
func (p *PolicyOperator) UpdatePolicy(sec, pType string, oldRule, newRule []string) error
UpdatePolicy replaces an existing rule.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is responsible for synchronization policy and storage policy by Raft protocol.
func (*Store) AddPolicies ¶
func (s *Store) AddPolicies(request *command.AddPoliciesRequest) error
AddPolicy implements the http.Store interface.
func (*Store) ClearPolicy ¶
ClearPolicy implements the http.Store interface.
func (*Store) IsInitializedCluster ¶
IsInitializedCluster checks whether the cluster has been initialized.
func (*Store) RemoveFilteredPolicy ¶
func (s *Store) RemoveFilteredPolicy(request *command.RemoveFilteredPolicyRequest) error
RemoveFilteredPolicy implements the http.Store interface.
func (*Store) RemoveNode ¶
RemoveNode implements the http.Store interface.
func (*Store) RemovePolicies ¶
func (s *Store) RemovePolicies(request *command.RemovePoliciesRequest) error
RemovePolicies implements the http.Store interface.
func (*Store) UpdatePolicies ¶
func (s *Store) UpdatePolicies(request *command.UpdatePoliciesRequest) error
UpdatePolicies implements the http.Store interface.
func (*Store) UpdatePolicy ¶
func (s *Store) UpdatePolicy(request *command.UpdatePolicyRequest) error
UpdatePolicy implements the http.Store interface.
func (*Store) WaitLeader ¶
WaitLeader detects the leader address in the current cluster.
type TCPStreamLayer ¶
type TCPStreamLayer struct {
// contains filtered or unexported fields
}
StreamLayer implements the raft.StreamLayer interface base on TCP.
func NewTCPStreamLayer ¶
NewStreamLayer returns a StreamLayer.
func (*TCPStreamLayer) Accept ¶
func (t *TCPStreamLayer) Accept() (c net.Conn, err error)
Accept implements the net.Listener interface.
func (*TCPStreamLayer) Addr ¶
func (t *TCPStreamLayer) Addr() net.Addr
Addr implements the net.Listener interface.
func (*TCPStreamLayer) Close ¶
func (t *TCPStreamLayer) Close() (err error)
Close implements the net.Listener interface.
func (*TCPStreamLayer) Dial ¶
func (t *TCPStreamLayer) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error)
Dial implements the StreamLayer interface.