Documentation ¶
Index ¶
- Constants
- Variables
- func CreateGRPCClient(key, endpoint string, autoRemove bool, create CreateService) error
- func Delete(key string) error
- func DeleteGRPCClient(key string)
- func DeleteTree(keyPrefix string) error
- func Exist(key string) bool
- func FillClusterAddrs(cfg *ClusterConfig, sys *system.SystemTools) error
- func ForceLeave(node string, server bool)
- func Get(key string) ([]byte, error)
- func GetClusterLead() string
- func GetGRPCClient(key string, isCompressed IsCompressedFunc, cb GRPCCallback) (interface{}, error)
- func GetGRPCClientEndpoint(key string) string
- func GetRev(key string) ([]byte, uint64, error)
- func GetSelfAddress() string
- func GetStoreKeys(store string) ([]string, error)
- func IsControllerGRPCCommpressed(endpoint string) bool
- func IsEnforcerGRPCCommpressed(endpoint string) bool
- func LeaveCluster(server bool)
- func List(keyPrefix string) (consulapi.KVPairs, error)
- func PauseAllWatchers(includeMonitorWatch bool)
- func PauseWatcher(key string)
- func Put(key string, value []byte) error
- func PutBinary(key string, value []byte) error
- func PutIfNotExist(key string, value []byte, logKeyOnly bool) error
- func PutQuiet(key string, value []byte) error
- func PutQuietRev(key string, value []byte, rev uint64) error
- func PutRev(key string, value []byte, rev uint64) error
- func RegisterKeyWatcher(key string, f KeyWatcher)
- func RegisterLeadChangeWatcher(fn LeadChangeCallback, lead string)
- func RegisterNodeWatcher(f NodeWatcher)
- func RegisterStateWatcher(f StateWatcher)
- func RegisterStoreWatcher(store string, f StoreWatcher, bCongestCtl bool)
- func RegisterWatcherMonitor(failFunc func() bool, recoverFunc func())
- func ResolveJoinAndBindAddr(joinAddr string, sys *system.SystemTools) (string, string, error)
- func ResumeAllWatchers()
- func ResumeWatcher(key string)
- func SetLogLevel(level log.Level)
- func SetWatcherCongestionCtl(key string, enabled bool)
- func StartCluster(cc *ClusterConfig) (string, error)
- type CLUSUnicast
- type ClusterConfig
- type ClusterDriver
- type ClusterMemberInfo
- type ClusterNotifyType
- type ClusterTransact
- func (t *ClusterTransact) Apply() (bool, error)
- func (t *ClusterTransact) CheckRev(key string, rev uint64)
- func (t *ClusterTransact) Close()
- func (t *ClusterTransact) Delete(key string)
- func (t *ClusterTransact) DeleteRev(key string, rev uint64)
- func (t *ClusterTransact) HasData() bool
- func (t *ClusterTransact) Put(key string, value []byte)
- func (t *ClusterTransact) PutBinary(key string, value []byte)
- func (t *ClusterTransact) PutQuiet(key string, value []byte)
- func (t *ClusterTransact) PutRev(key string, value []byte, rev uint64)
- func (t *ClusterTransact) Reset()
- func (t *ClusterTransact) Size() int
- type CreateService
- type GRPCCallback
- type GRPCClient
- type GRPCServer
- type IsCompressedFunc
- type KeyWatcher
- type LeadChangeCallback
- type LockInterface
- type MessengerInterface
- type MockEvQueue
- type MockMessenger
- func (msgr *MockMessenger) UniackStore() string
- func (msgr *MockMessenger) UniackUpdateHandler(nType ClusterNotifyType, key string, value []byte, unused uint64)
- func (msgr *MockMessenger) Unicast(target string, subject string, data []byte, cb UnicastCallback, timeout int, ...) error
- func (msgr *MockMessenger) UnicastKey2Subject(key string) string
- func (msgr *MockMessenger) UnicastStore(target string) string
- type NodeWatcher
- type ObjectQueueInterface
- type Service
- type SessionInterface
- type StateWatcher
- type StoreWatcher
- type UnicastCallback
Constants ¶
View Source
const ( ClusterNotifyAdd = iota ClusterNotifyModify ClusterNotifyDelete ClusterNotifyStateOnline ClusterNotifyStateOffline )
View Source
const ( NodeRoleServer = iota NodeRoleClient )
View Source
const ( NodeStateAlive = iota NodeStateLeft NodeStateFail )
View Source
const CLUSUniackStore string = "uniack/"
View Source
const CLUSUnicastStore string = "unicast/"
View Source
const CONSUL_KV_BASE_URL = "http://localhost:8500/v1/kv"
View Source
const DefaultAgentGRPCPort = 18401
View Source
const DefaultControllerGRPCPort = 18400
View Source
const DefaultDataCenter string = "neuvector"
View Source
const DefaultMaxQLen = 4096
View Source
const DefaultScannerGRPCPort = 18402
View Source
const GRPCMaxMsgSize = 1024 * 1024 * 32
Variables ¶
View Source
var ClusterNotifyName = []string{ ClusterNotifyAdd: "add", ClusterNotifyModify: "modify", ClusterNotifyDelete: "delete", ClusterNotifyStateOnline: "connect", ClusterNotifyStateOffline: "disconnect", }
View Source
var ErrEmptyStore error = errors.New("Empty store")
View Source
var ErrKeyNotFound error = errors.New("Key not found")
View Source
var ErrQueueFull = errors.New("Queue full")
View Source
var KVValueSizeMax = 512 * 1024
Functions ¶
func CreateGRPCClient ¶
func CreateGRPCClient(key, endpoint string, autoRemove bool, create CreateService) error
func DeleteGRPCClient ¶
func DeleteGRPCClient(key string)
func DeleteTree ¶
func FillClusterAddrs ¶
func FillClusterAddrs(cfg *ClusterConfig, sys *system.SystemTools) error
func ForceLeave ¶
func GetClusterLead ¶
func GetClusterLead() string
func GetGRPCClient ¶
func GetGRPCClient(key string, isCompressed IsCompressedFunc, cb GRPCCallback) (interface{}, error)
func GetGRPCClientEndpoint ¶
func GetSelfAddress ¶
func GetSelfAddress() string
func GetStoreKeys ¶
func LeaveCluster ¶
func LeaveCluster(server bool)
func PauseAllWatchers ¶
func PauseAllWatchers(includeMonitorWatch bool)
func PauseWatcher ¶
func PauseWatcher(key string)
func PutIfNotExist ¶
The difference between putRev(k, v, 0) and PutIfNotExist(k, v) is the later return nil error when the key exists
func RegisterKeyWatcher ¶
func RegisterKeyWatcher(key string, f KeyWatcher)
func RegisterLeadChangeWatcher ¶
func RegisterLeadChangeWatcher(fn LeadChangeCallback, lead string)
func RegisterNodeWatcher ¶
func RegisterNodeWatcher(f NodeWatcher)
func RegisterStateWatcher ¶
func RegisterStateWatcher(f StateWatcher)
func RegisterStoreWatcher ¶
func RegisterStoreWatcher(store string, f StoreWatcher, bCongestCtl bool)
func RegisterWatcherMonitor ¶
func RegisterWatcherMonitor(failFunc func() bool, recoverFunc func())
func ResolveJoinAndBindAddr ¶
func ResumeAllWatchers ¶
func ResumeAllWatchers()
func ResumeWatcher ¶
func ResumeWatcher(key string)
func SetLogLevel ¶
func SetWatcherCongestionCtl ¶
func StartCluster ¶
func StartCluster(cc *ClusterConfig) (string, error)
Types ¶
type CLUSUnicast ¶
type ClusterConfig ¶
type ClusterDriver ¶
type ClusterDriver interface { Start(cc *ClusterConfig, eCh chan error, recover bool) Join(cc *ClusterConfig) error Leave(server bool) error ForceLeave(node string, server bool) error Reload(cc *ClusterConfig) error GetSelfAddress() string GetLead() (string, error) ServerAlive() (bool, error) GetAllMembers() []ClusterMemberInfo NewLock(key string, wait time.Duration) (LockInterface, error) NewSession(name string, ttl time.Duration) (SessionInterface, error) // KV Exist(key string) bool Get(key string) ([]byte, error) GetRev(key string) ([]byte, uint64, error) GetStoreKeys(store string) ([]string, error) Put(key string, value []byte) error PutRev(key string, value []byte, rev uint64) error PutIfNotExist(key string, value []byte) error Delete(key string) error List(keyPrefix string) (consulapi.KVPairs, error) DeleteTree(keyPrefix string) error Transact([]transactEntry) (bool, error) // Watcher RegisterKeyWatcher(key string, watcher KeyWatcher) RegisterStoreWatcher(store string, watcher StoreWatcher, bCongestCtl bool) RegisterStateWatcher(watcher StateWatcher) RegisterNodeWatcher(watcher NodeWatcher) RegisterWatcherMonitor(failFunc func() bool, recoverFunc func()) RegisterExistingWatchers() StopAllWatchers() PauseAllWatchers(includeMonitorWatch bool) ResumeAllWatchers() PauseWatcher(key string) ResumeWatcher(key string) SetWatcherCongestionCtl(key string, enabled bool) }
type ClusterMemberInfo ¶
func GetAllMembers ¶
func GetAllMembers() []ClusterMemberInfo
type ClusterNotifyType ¶
type ClusterNotifyType int
type ClusterTransact ¶
type ClusterTransact struct {
// contains filtered or unexported fields
}
func Transact ¶
func Transact() *ClusterTransact
func (*ClusterTransact) Apply ¶
func (t *ClusterTransact) Apply() (bool, error)
func (*ClusterTransact) CheckRev ¶
func (t *ClusterTransact) CheckRev(key string, rev uint64)
func (*ClusterTransact) Close ¶
func (t *ClusterTransact) Close()
func (*ClusterTransact) Delete ¶
func (t *ClusterTransact) Delete(key string)
func (*ClusterTransact) DeleteRev ¶
func (t *ClusterTransact) DeleteRev(key string, rev uint64)
func (*ClusterTransact) HasData ¶
func (t *ClusterTransact) HasData() bool
func (*ClusterTransact) Put ¶
func (t *ClusterTransact) Put(key string, value []byte)
func (*ClusterTransact) PutBinary ¶
func (t *ClusterTransact) PutBinary(key string, value []byte)
func (*ClusterTransact) PutQuiet ¶
func (t *ClusterTransact) PutQuiet(key string, value []byte)
func (*ClusterTransact) PutRev ¶
func (t *ClusterTransact) PutRev(key string, value []byte, rev uint64)
func (*ClusterTransact) Reset ¶
func (t *ClusterTransact) Reset()
func (*ClusterTransact) Size ¶
func (t *ClusterTransact) Size() int
type CreateService ¶
type CreateService func(conn *grpc.ClientConn) Service
type GRPCCallback ¶
type GRPCCallback interface {
Shutdown()
}
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
func (*GRPCClient) Close ¶
func (c *GRPCClient) Close()
func (*GRPCClient) GetClient ¶
func (c *GRPCClient) GetClient() *grpc.ClientConn
type GRPCServer ¶
type GRPCServer struct {
// contains filtered or unexported fields
}
func NewGRPCServerTCP ¶
func NewGRPCServerTCP(endpoint string) (*GRPCServer, error)
func NewGRPCServerUnix ¶
func NewGRPCServerUnix(socket string) (*GRPCServer, error)
func (*GRPCServer) GetServer ¶
func (s *GRPCServer) GetServer() *grpc.Server
func (*GRPCServer) GracefulStop ¶
func (s *GRPCServer) GracefulStop()
func (*GRPCServer) Start ¶
func (s *GRPCServer) Start()
func (*GRPCServer) Stop ¶
func (s *GRPCServer) Stop()
type IsCompressedFunc ¶
type KeyWatcher ¶
type KeyWatcher func(ClusterNotifyType, string, []byte, uint64)
type LeadChangeCallback ¶
type LockInterface ¶
type MessengerInterface ¶
type MessengerInterface interface { Unicast(target string, subject string, data []byte, cb UnicastCallback, timeout int, args ...interface{}) error UnicastStore(target string) string UnicastKey2Subject(key string) string UniackStore() string UniackUpdateHandler(nType ClusterNotifyType, key string, value []byte, unused uint64) }
func NewMessenger ¶
func NewMessenger(hostID string, devID string) MessengerInterface
type MockEvQueue ¶
type MockEvQueue struct { }
func (*MockEvQueue) Append ¶
func (evq *MockEvQueue) Append(interface{}) error
func (*MockEvQueue) Flush ¶
func (evq *MockEvQueue) Flush() error
type MockMessenger ¶
type MockMessenger struct { }
func (*MockMessenger) UniackStore ¶
func (msgr *MockMessenger) UniackStore() string
func (*MockMessenger) UniackUpdateHandler ¶
func (msgr *MockMessenger) UniackUpdateHandler(nType ClusterNotifyType, key string, value []byte, unused uint64)
func (*MockMessenger) Unicast ¶
func (msgr *MockMessenger) Unicast(target string, subject string, data []byte, cb UnicastCallback, timeout int, args ...interface{}) error
func (*MockMessenger) UnicastKey2Subject ¶
func (msgr *MockMessenger) UnicastKey2Subject(key string) string
func (*MockMessenger) UnicastStore ¶
func (msgr *MockMessenger) UnicastStore(target string) string
type NodeWatcher ¶
type NodeWatcher func(ClusterNotifyType, string, string)
type ObjectQueueInterface ¶
func NewObjectQueue ¶
func NewObjectQueue(key string, maxQLen int) ObjectQueueInterface
type Service ¶
type Service interface{}
* ---------------------------------------------------- * ---------- Client management ----------------------- * ----------------------------------------------------
type SessionInterface ¶
Session is a mechanism to implement short-lived keys. When the session is created, a TTL value is given. Keys are "associated" with the session will be deleted when the session expires.
func NewSession ¶
func NewSession(name string, ttl time.Duration) (SessionInterface, error)
type StateWatcher ¶
type StateWatcher func(ClusterNotifyType, string, string)
type StoreWatcher ¶
type StoreWatcher func(ClusterNotifyType, string, []byte, uint64)
type UnicastCallback ¶
Click to show internal directories.
Click to hide internal directories.