cluster

package
v1.25.0-119.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 26 Imported by: 5

Documentation

Overview

Package cluster is a generated GoMock package.

Index

Constants

View Source
const (
	// TestCurrentClusterInitialFailoverVersion is initial failover version for current cluster
	TestCurrentClusterInitialFailoverVersion = int64(1)
	// TestAlternativeClusterInitialFailoverVersion is initial failover version for alternative cluster
	TestAlternativeClusterInitialFailoverVersion = int64(2)
	// TestFailoverVersionIncrement is failover version increment used for test
	TestFailoverVersionIncrement = int64(10)
	// TestCurrentClusterName is current cluster used for test
	TestCurrentClusterName = "active"
	// TestAlternativeClusterName is alternative cluster used for test
	TestAlternativeClusterName = "standby"
	// TestCurrentClusterFrontendAddress is the ip port address of current cluster
	TestCurrentClusterFrontendAddress = "127.0.0.1:7134"
	// TestAlternativeClusterFrontendAddress is the ip port address of alternative cluster
	TestAlternativeClusterFrontendAddress = "127.0.0.1:8134"
	// TestCurrentClusterFrontendHTTPAddress is the ip port HTTP address of current cluster. Currently, gRPC port+10. See tests/onebox.go:FrontendHTTPAddress
	TestCurrentClusterFrontendHTTPAddress = "127.0.0.1:7144"
	// TestAlternativeClusterFrontendHTTPAddress is the ip port HTTP address of the alternative cluster. Currently, gRPC port+10. See tests/onebox.go:FrontendHTTPAddress
	TestAlternativeClusterFrontendHTTPAddress = "127.0.0.1:8144"
)

Variables

View Source
var (
	// TestAllClusterNames is the all cluster names used for test
	TestAllClusterNames = []string{TestCurrentClusterName, TestAlternativeClusterName}
	// TestAllClusterInfo is the same as above, just convenient for test mocking
	TestAllClusterInfo = map[string]ClusterInformation{
		TestCurrentClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion,
			RPCAddress:             TestCurrentClusterFrontendAddress,
			HTTPAddress:            TestCurrentClusterFrontendHTTPAddress,
			ShardCount:             8,
			ClusterID:              uuid.NewString(),
		},
		TestAlternativeClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestAlternativeClusterInitialFailoverVersion,
			RPCAddress:             TestAlternativeClusterFrontendAddress,
			HTTPAddress:            TestAlternativeClusterFrontendHTTPAddress,
			ShardCount:             4,
			ClusterID:              uuid.NewString(),
		},
	}

	// TestSingleDCAllClusterNames is the all cluster names used for test
	TestSingleDCAllClusterNames = []string{TestCurrentClusterName}
	// TestSingleDCClusterInfo is the same as above, just convenient for test mocking
	TestSingleDCClusterInfo = map[string]ClusterInformation{
		TestCurrentClusterName: {
			Enabled:                true,
			InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion,
			RPCAddress:             TestCurrentClusterFrontendAddress,
			HTTPAddress:            TestCurrentClusterFrontendHTTPAddress,
			ClusterID:              uuid.NewString(),
		},
	}
)
View Source
var MetadataLifetimeHooksModule = fx.Options(
	fx.Provide(NewMetadataFromConfig),
	fx.Invoke(MetadataLifetimeHooks),
	fx.Provide(fx.Annotate(
		func(p Metadata) pingable.Pingable { return p },
		fx.ResultTags(`group:"deadlockDetectorRoots"`),
	)),
)

Functions

func GetAllClustersIter added in v1.24.0

GetAllClustersIter returns an iterator that can be used to iterate over all clusters in the metadata store.

func MetadataLifetimeHooks added in v1.14.4

func MetadataLifetimeHooks(
	lc fx.Lifecycle,
	clusterMetadata Metadata,
)

Types

type CallbackFn added in v1.14.0

type CallbackFn func(oldClusterMetadata map[string]*ClusterInformation, newClusterMetadata map[string]*ClusterInformation)

type ClusterInformation added in v1.14.0

type ClusterInformation struct {
	Enabled                bool  `yaml:"enabled"`
	InitialFailoverVersion int64 `yaml:"initialFailoverVersion"`
	// RPCAddress indicate the remote service address(Host:Port). Host can be DNS name.
	RPCAddress string `yaml:"rpcAddress"`
	// HTTPAddress indicates the address of the [go.temporal.io/server/service/frontend.HTTPAPIServer].
	// E.g. "localhost:7243".
	HTTPAddress string `yaml:"httpAddress"`
	// ClusterID allows to explicitly set the ID of the cluster. Optional.
	ClusterID  string            `yaml:"-"`
	ShardCount int32             `yaml:"-"` // Ignore this field when loading config.
	Tags       map[string]string `yaml:"-"` // Ignore this field. Use cluster.Config.Tags for customized tags.
	// contains filtered or unexported fields
}

ClusterInformation contains information for a single cluster.

func ClusterInformationFromDB added in v1.24.0

func ClusterInformationFromDB(getClusterResp *persistence.GetClusterMetadataResponse) *ClusterInformation

func ShallowCopyClusterInformation added in v1.24.0

func ShallowCopyClusterInformation(information *ClusterInformation) *ClusterInformation

ShallowCopyClusterInformation returns a shallow copy of the given ClusterInformation. The [ClusterInformation.Tags] field is not deep-copied, so you must be careful when modifying it.

type Config added in v1.14.0

type Config struct {
	EnableGlobalNamespace bool `yaml:"enableGlobalNamespace"`
	// FailoverVersionIncrement is the increment of each cluster version when failover happens.
	FailoverVersionIncrement int64 `yaml:"failoverVersionIncrement"`
	// MasterClusterName is the master cluster name, only the master cluster can register / update namespace
	// all clusters can do namespace failover.
	MasterClusterName string `yaml:"masterClusterName"`
	// CurrentClusterName is the name of the current cluster.
	CurrentClusterName string `yaml:"currentClusterName"`
	// ClusterInformation is a map from cluster name to corresponding information for each registered cluster.
	ClusterInformation map[string]ClusterInformation `yaml:"clusterInformation"`
	// Tags contains customized tags for the current cluster.
	Tags map[string]string `yaml:"tags"`
}

Config contains the all cluster which participated in cross DC

func NewTestClusterMetadataConfig added in v1.10.0

func NewTestClusterMetadataConfig(enableGlobalNamespace bool, isMasterCluster bool) *Config

NewTestClusterMetadataConfig return an cluster metadata config

type FrontendHTTPClientCache added in v1.25.0

type FrontendHTTPClientCache struct {
	// contains filtered or unexported fields
}

func NewFrontendHTTPClientCache added in v1.25.0

func NewFrontendHTTPClientCache(
	metadata Metadata,
	tlsProvider tlsConfigProvider,
) *FrontendHTTPClientCache

func (*FrontendHTTPClientCache) Get added in v1.25.0

func (c *FrontendHTTPClientCache) Get(targetClusterName string) (*common.FrontendHTTPClient, error)

Get returns a cached HttpClient if available, or constructs a new one for the given cluster name.

type Metadata

type Metadata interface {
	pingable.Pingable

	// IsGlobalNamespaceEnabled whether the global namespace is enabled,
	// this attr should be discarded when cross DC is made public
	IsGlobalNamespaceEnabled() bool
	// IsMasterCluster whether current cluster is master cluster
	IsMasterCluster() bool
	// GetClusterID return the cluster ID, which is also the initial failover version
	GetClusterID() int64
	// GetNextFailoverVersion return the next failover version for namespace failover
	GetNextFailoverVersion(string, int64) int64
	// IsVersionFromSameCluster return true if 2 version are used for the same cluster
	IsVersionFromSameCluster(version1 int64, version2 int64) bool
	// GetMasterClusterName return the master cluster name
	GetMasterClusterName() string
	// GetCurrentClusterName return the current cluster name
	GetCurrentClusterName() string
	// GetAllClusterInfo return the all cluster name -> corresponding info
	GetAllClusterInfo() map[string]ClusterInformation
	// ClusterNameForFailoverVersion return the corresponding cluster name for a given failover version
	ClusterNameForFailoverVersion(isGlobalNamespace bool, failoverVersion int64) string
	// GetFailoverVersionIncrement return the Failover version increment value
	GetFailoverVersionIncrement() int64
	RegisterMetadataChangeCallback(callbackId any, cb CallbackFn)
	UnRegisterMetadataChangeCallback(callbackId any)
	Start()
	Stop()
}

Metadata provides information about the current cluster and other registered remote clusters.

func NewMetadata

func NewMetadata(
	enableGlobalNamespace bool,
	failoverVersionIncrement int64,
	masterClusterName string,
	currentClusterName string,
	clusterInfo map[string]ClusterInformation,
	clusterMetadataStore persistence.ClusterMetadataManager,
	refreshDuration dynamicconfig.DurationPropertyFn,
	logger log.Logger,
) Metadata

func NewMetadataFromConfig added in v1.14.0

func NewMetadataFromConfig(
	config *Config,
	clusterMetadataStore persistence.ClusterMetadataManager,
	dynamicCollection *dynamicconfig.Collection,
	logger log.Logger,
) Metadata

type MockMetadata added in v0.27.0

type MockMetadata struct {
	// contains filtered or unexported fields
}

MockMetadata is a mock of Metadata interface.

func NewMockMetadata added in v0.27.0

func NewMockMetadata(ctrl *gomock.Controller) *MockMetadata

NewMockMetadata creates a new mock instance.

func (*MockMetadata) ClusterNameForFailoverVersion added in v0.27.0

func (m *MockMetadata) ClusterNameForFailoverVersion(isGlobalNamespace bool, failoverVersion int64) string

ClusterNameForFailoverVersion mocks base method.

func (*MockMetadata) EXPECT added in v0.27.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetadata) GetAllClusterInfo added in v0.27.0

func (m *MockMetadata) GetAllClusterInfo() map[string]ClusterInformation

GetAllClusterInfo mocks base method.

func (*MockMetadata) GetClusterID added in v1.17.0

func (m *MockMetadata) GetClusterID() int64

GetClusterID mocks base method.

func (*MockMetadata) GetCurrentClusterName added in v0.27.0

func (m *MockMetadata) GetCurrentClusterName() string

GetCurrentClusterName mocks base method.

func (*MockMetadata) GetFailoverVersionIncrement added in v1.14.0

func (m *MockMetadata) GetFailoverVersionIncrement() int64

GetFailoverVersionIncrement mocks base method.

func (*MockMetadata) GetMasterClusterName added in v0.27.0

func (m *MockMetadata) GetMasterClusterName() string

GetMasterClusterName mocks base method.

func (*MockMetadata) GetNextFailoverVersion added in v0.27.0

func (m *MockMetadata) GetNextFailoverVersion(arg0 string, arg1 int64) int64

GetNextFailoverVersion mocks base method.

func (*MockMetadata) GetPingChecks added in v1.19.0

func (m *MockMetadata) GetPingChecks() []pingable.Check

GetPingChecks mocks base method.

func (*MockMetadata) IsGlobalNamespaceEnabled added in v0.27.0

func (m *MockMetadata) IsGlobalNamespaceEnabled() bool

IsGlobalNamespaceEnabled mocks base method.

func (*MockMetadata) IsMasterCluster added in v0.27.0

func (m *MockMetadata) IsMasterCluster() bool

IsMasterCluster mocks base method.

func (*MockMetadata) IsVersionFromSameCluster added in v0.27.0

func (m *MockMetadata) IsVersionFromSameCluster(version1, version2 int64) bool

IsVersionFromSameCluster mocks base method.

func (*MockMetadata) RegisterMetadataChangeCallback added in v1.14.0

func (m *MockMetadata) RegisterMetadataChangeCallback(callbackId any, cb CallbackFn)

RegisterMetadataChangeCallback mocks base method.

func (*MockMetadata) Start added in v1.14.0

func (m *MockMetadata) Start()

Start mocks base method.

func (*MockMetadata) Stop added in v1.14.0

func (m *MockMetadata) Stop()

Stop mocks base method.

func (*MockMetadata) UnRegisterMetadataChangeCallback added in v1.14.0

func (m *MockMetadata) UnRegisterMetadataChangeCallback(callbackId any)

UnRegisterMetadataChangeCallback mocks base method.

type MockMetadataMockRecorder added in v0.27.0

type MockMetadataMockRecorder struct {
	// contains filtered or unexported fields
}

MockMetadataMockRecorder is the mock recorder for MockMetadata.

func (*MockMetadataMockRecorder) ClusterNameForFailoverVersion added in v0.27.0

func (mr *MockMetadataMockRecorder) ClusterNameForFailoverVersion(isGlobalNamespace, failoverVersion interface{}) *gomock.Call

ClusterNameForFailoverVersion indicates an expected call of ClusterNameForFailoverVersion.

func (*MockMetadataMockRecorder) GetAllClusterInfo added in v0.27.0

func (mr *MockMetadataMockRecorder) GetAllClusterInfo() *gomock.Call

GetAllClusterInfo indicates an expected call of GetAllClusterInfo.

func (*MockMetadataMockRecorder) GetClusterID added in v1.17.0

func (mr *MockMetadataMockRecorder) GetClusterID() *gomock.Call

GetClusterID indicates an expected call of GetClusterID.

func (*MockMetadataMockRecorder) GetCurrentClusterName added in v0.27.0

func (mr *MockMetadataMockRecorder) GetCurrentClusterName() *gomock.Call

GetCurrentClusterName indicates an expected call of GetCurrentClusterName.

func (*MockMetadataMockRecorder) GetFailoverVersionIncrement added in v1.14.0

func (mr *MockMetadataMockRecorder) GetFailoverVersionIncrement() *gomock.Call

GetFailoverVersionIncrement indicates an expected call of GetFailoverVersionIncrement.

func (*MockMetadataMockRecorder) GetMasterClusterName added in v0.27.0

func (mr *MockMetadataMockRecorder) GetMasterClusterName() *gomock.Call

GetMasterClusterName indicates an expected call of GetMasterClusterName.

func (*MockMetadataMockRecorder) GetNextFailoverVersion added in v0.27.0

func (mr *MockMetadataMockRecorder) GetNextFailoverVersion(arg0, arg1 interface{}) *gomock.Call

GetNextFailoverVersion indicates an expected call of GetNextFailoverVersion.

func (*MockMetadataMockRecorder) GetPingChecks added in v1.19.0

func (mr *MockMetadataMockRecorder) GetPingChecks() *gomock.Call

GetPingChecks indicates an expected call of GetPingChecks.

func (*MockMetadataMockRecorder) IsGlobalNamespaceEnabled added in v0.27.0

func (mr *MockMetadataMockRecorder) IsGlobalNamespaceEnabled() *gomock.Call

IsGlobalNamespaceEnabled indicates an expected call of IsGlobalNamespaceEnabled.

func (*MockMetadataMockRecorder) IsMasterCluster added in v0.27.0

func (mr *MockMetadataMockRecorder) IsMasterCluster() *gomock.Call

IsMasterCluster indicates an expected call of IsMasterCluster.

func (*MockMetadataMockRecorder) IsVersionFromSameCluster added in v0.27.0

func (mr *MockMetadataMockRecorder) IsVersionFromSameCluster(version1, version2 interface{}) *gomock.Call

IsVersionFromSameCluster indicates an expected call of IsVersionFromSameCluster.

func (*MockMetadataMockRecorder) RegisterMetadataChangeCallback added in v1.14.0

func (mr *MockMetadataMockRecorder) RegisterMetadataChangeCallback(callbackId, cb interface{}) *gomock.Call

RegisterMetadataChangeCallback indicates an expected call of RegisterMetadataChangeCallback.

func (*MockMetadataMockRecorder) Start added in v1.14.0

func (mr *MockMetadataMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start.

func (*MockMetadataMockRecorder) Stop added in v1.14.0

func (mr *MockMetadataMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop.

func (*MockMetadataMockRecorder) UnRegisterMetadataChangeCallback added in v1.14.0

func (mr *MockMetadataMockRecorder) UnRegisterMetadataChangeCallback(callbackId interface{}) *gomock.Call

UnRegisterMetadataChangeCallback indicates an expected call of UnRegisterMetadataChangeCallback.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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