clusterservice

package
v1.0.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EQ ==
	EQ = Op(1)
)

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)
	// 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
}

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 Op

type Op int

Op compare op

type Option

type Option func(*cluster)

Option options for create cluster

func WithDisableRefresh

func WithDisableRefresh() Option

WithDisableRefresh disable refresh from hakeeper

func WithServices

func WithServices(
	cnServices []metadata.CNService,
	tnServices []metadata.TNService) Option

WithServices set init cn and tn services

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

func NewServiceIDSelector(serviceID string) Selector

NewServiceIDSelector

func (Selector) LabelNum added in v1.0.0

func (s Selector) LabelNum() int

LabelNum returns the number of labels in this selector.

func (Selector) SelectByLabel

func (s Selector) SelectByLabel(labels map[string]string, op Op) Selector

SelectByLabel select service by label

func (Selector) SelectByServiceID

func (s Selector) SelectByServiceID(serviceID string) Selector

SelectByServiceID select service by service ID

func (Selector) SelectWithoutLabel added in v1.0.0

func (s Selector) SelectWithoutLabel(labels map[string]string) Selector

SelectWithoutLabel updates the selector by removing the labels.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL