Documentation ¶
Index ¶
- Variables
- type ClusterClient
- type MOCluster
- type Op
- type Option
- type Selector
- func (s Selector) LabelNum() int
- func (s Selector) Match(labels map[string]metadata.LabelList) bool
- func (s Selector) SelectByLabel(labels map[string]string, op Op) Selector
- func (s Selector) SelectByServiceID(serviceID string) Selector
- func (s Selector) SelectWithoutLabel(labels map[string]string) Selector
Constants ¶
This section is empty.
Variables ¶
var ( // EQ == EQ = Op(1) // EQ_Globbing means the labels are equal, also support globbing(*) // to match key/value from request. EQ_Globbing = Op(2) // Contain means the requested labels are contained in the CN labels. Contain = Op(3) )
Functions ¶
This section is empty.
Types ¶
type ClusterClient ¶
type ClusterClient interface {
GetClusterDetails(ctx context.Context) (logpb.ClusterDetails, error)
}
type MOCluster ¶
type MOCluster interface { // GetCNService get services by selector, and the applyFunc used to save the // cn service that matches the selector's conditions. // // Since the query result may be a Slice, to avoid memory allocation overhead, // we use apply to notify the caller of a Service that satisfies the condition. GetCNService(selector Selector, apply func(metadata.CNService) bool) // GetTNService get services by selector, and the applyFunc used to save the // tn service that matches the selector's conditions. // // Since the query result may be a Slice, to avoid memory allocation overhead, // we use apply to notify the caller of a Service that satisfies the condition. GetTNService(selector Selector, apply func(metadata.TNService) bool) // GetAllTNServices get all tn services GetAllTNServices() []metadata.TNService // GetCNServiceWithoutWorkingState get services by selector, and the applyFunc used to save the // cn service that matches the selector's conditions. // // Since the query result may be a Slice, to avoid memory allocation overhead, // we use apply to notify the caller of a Service that satisfies the condition. GetCNServiceWithoutWorkingState(selector Selector, apply func(metadata.CNService) bool) // ForceRefresh when other modules use the cluster information and find out that // the current cache information is out of date, you can force the cache to be // refreshed. ForceRefresh(sync bool) // Close close the cluster Close() // DebugUpdateCNLabel updates the labels on specified CN. It is only used in mo_ctl // internally for debug purpose. DebugUpdateCNLabel(uuid string, kvs map[string][]string) error DebugUpdateCNWorkState(uuid string, state int) error // RemoveCN removes the specified CN from the cluster RemoveCN(id string) // AddCN adds the specified CN to the cluster AddCN(metadata.CNService) }
MOCluster is used to get the meta and status information of the MO cluster.
TODO(fagongzi): In the future, all cluster-related information should be obtained from this interface, such as the distribution of table data on cn and other statistical information.
func GetMOCluster ¶
func GetMOCluster() MOCluster
GetMOCluster get mo cluster from process level runtime
func NewMOCluster ¶
func NewMOCluster( client ClusterClient, refreshInterval time.Duration, opts ...Option) MOCluster
NewMOCluster create a MOCluter by HAKeeperClient. MoCluster synchronizes information from HAKeeper and forcibly refreshes the information once every refreshInterval.
TODO(fagongzi): extend hakeeper to support event-driven original message changes
type Option ¶
type Option func(*cluster)
Option options for create cluster
func WithDisableRefresh ¶
func WithDisableRefresh() Option
WithDisableRefresh disable refresh from hakeeper
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector is used to choose a service from MOCluster
func NewSelectAll ¶ added in v1.0.0
func NewSelectAll() Selector
NewSelectAll will return all CN services.
func NewSelector ¶
func NewSelector() Selector
NewSelector return a default selector, this empty selector will select all instances. For CN type, it only select the ones whose work state is working.
func NewServiceIDSelector ¶
NewServiceIDSelector
func (Selector) Match ¶ added in v1.1.2
Match check if @labels match the selector. At most case, the selector's labels is subset of @labels
return true, if @labels is empty.
func (Selector) SelectByLabel ¶
SelectByLabel select service by label
func (Selector) SelectByServiceID ¶
SelectByServiceID select service by service ID