cluster

package
v1.32.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 27 Imported by: 0

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

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

func IsReplicationEnabledForCluster

func IsReplicationEnabledForCluster(clusterInfo ClusterInformation, enableSeparateReplicationFlag bool) bool

IsReplicationEnabledForCluster checks if replication is enabled for a cluster, considering the feature flag. When enableSeparateReplicationFlag is false, it falls back to only checking the Enabled flag. This is a shared helper function used across history service components.

func MetadataLifetimeHooks

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

func ValidateClusterInformation

func ValidateClusterInformation(
	clusterName string,
	info ClusterInformation,
	failoverVersionIncrement int64,
) error

ValidateClusterInformation checks the invariants that NewMetadata and the runtime refresh both depend on. It is also used at admin/operator RPC boundaries so that bad input is rejected before it can be persisted and later crash the metadata refresher.

Types

type CallbackFn

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

type ClusterInformation

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 [github.com/superdurable/xtemporal/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.
	// ReplicationEnabled controls whether replication streams are active.
	ReplicationEnabled bool `yaml:"-"`
	// contains filtered or unexported fields
}

ClusterInformation contains information for a single cluster.

func ClusterInformationFromDB

func ClusterInformationFromDB(getClusterResp *persistence.GetClusterMetadataResponse) *ClusterInformation

func ShallowCopyClusterInformation

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

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

func NewTestClusterMetadataConfig(enableGlobalNamespace bool, isMasterCluster bool) *Config

NewTestClusterMetadataConfig return an cluster metadata config

type FrontendHTTPClientCache

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

func NewFrontendHTTPClientCache

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

func (*FrontendHTTPClientCache) Get

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

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

type MockMetadata

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

MockMetadata is a mock of Metadata interface.

func NewMockMetadata

func NewMockMetadata(ctrl *gomock.Controller) *MockMetadata

NewMockMetadata creates a new mock instance.

func (*MockMetadata) ClusterNameForFailoverVersion

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

ClusterNameForFailoverVersion mocks base method.

func (*MockMetadata) EXPECT

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

func (*MockMetadata) GetAllClusterInfo

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

GetAllClusterInfo mocks base method.

func (*MockMetadata) GetClusterID

func (m *MockMetadata) GetClusterID() int64

GetClusterID mocks base method.

func (*MockMetadata) GetCurrentClusterName

func (m *MockMetadata) GetCurrentClusterName() string

GetCurrentClusterName mocks base method.

func (*MockMetadata) GetFailoverVersionIncrement

func (m *MockMetadata) GetFailoverVersionIncrement() int64

GetFailoverVersionIncrement mocks base method.

func (*MockMetadata) GetMasterClusterName

func (m *MockMetadata) GetMasterClusterName() string

GetMasterClusterName mocks base method.

func (*MockMetadata) GetNextFailoverVersion

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

GetNextFailoverVersion mocks base method.

func (*MockMetadata) GetPingChecks

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

GetPingChecks mocks base method.

func (*MockMetadata) IsGlobalNamespaceEnabled

func (m *MockMetadata) IsGlobalNamespaceEnabled() bool

IsGlobalNamespaceEnabled mocks base method.

func (*MockMetadata) IsMasterCluster

func (m *MockMetadata) IsMasterCluster() bool

IsMasterCluster mocks base method.

func (*MockMetadata) IsVersionFromSameCluster

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

IsVersionFromSameCluster mocks base method.

func (*MockMetadata) RegisterMetadataChangeCallback

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

RegisterMetadataChangeCallback mocks base method.

func (*MockMetadata) Start

func (m *MockMetadata) Start()

Start mocks base method.

func (*MockMetadata) Stop

func (m *MockMetadata) Stop()

Stop mocks base method.

func (*MockMetadata) UnRegisterMetadataChangeCallback

func (m *MockMetadata) UnRegisterMetadataChangeCallback(callbackId any)

UnRegisterMetadataChangeCallback mocks base method.

type MockMetadataMockRecorder

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

MockMetadataMockRecorder is the mock recorder for MockMetadata.

func (*MockMetadataMockRecorder) ClusterNameForFailoverVersion

func (mr *MockMetadataMockRecorder) ClusterNameForFailoverVersion(isGlobalNamespace, failoverVersion any) *gomock.Call

ClusterNameForFailoverVersion indicates an expected call of ClusterNameForFailoverVersion.

func (*MockMetadataMockRecorder) GetAllClusterInfo

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

GetAllClusterInfo indicates an expected call of GetAllClusterInfo.

func (*MockMetadataMockRecorder) GetClusterID

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

GetClusterID indicates an expected call of GetClusterID.

func (*MockMetadataMockRecorder) GetCurrentClusterName

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

GetCurrentClusterName indicates an expected call of GetCurrentClusterName.

func (*MockMetadataMockRecorder) GetFailoverVersionIncrement

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

GetFailoverVersionIncrement indicates an expected call of GetFailoverVersionIncrement.

func (*MockMetadataMockRecorder) GetMasterClusterName

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

GetMasterClusterName indicates an expected call of GetMasterClusterName.

func (*MockMetadataMockRecorder) GetNextFailoverVersion

func (mr *MockMetadataMockRecorder) GetNextFailoverVersion(arg0, arg1 any) *gomock.Call

GetNextFailoverVersion indicates an expected call of GetNextFailoverVersion.

func (*MockMetadataMockRecorder) GetPingChecks

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

GetPingChecks indicates an expected call of GetPingChecks.

func (*MockMetadataMockRecorder) IsGlobalNamespaceEnabled

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

IsGlobalNamespaceEnabled indicates an expected call of IsGlobalNamespaceEnabled.

func (*MockMetadataMockRecorder) IsMasterCluster

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

IsMasterCluster indicates an expected call of IsMasterCluster.

func (*MockMetadataMockRecorder) IsVersionFromSameCluster

func (mr *MockMetadataMockRecorder) IsVersionFromSameCluster(version1, version2 any) *gomock.Call

IsVersionFromSameCluster indicates an expected call of IsVersionFromSameCluster.

func (*MockMetadataMockRecorder) RegisterMetadataChangeCallback

func (mr *MockMetadataMockRecorder) RegisterMetadataChangeCallback(callbackId, cb any) *gomock.Call

RegisterMetadataChangeCallback indicates an expected call of RegisterMetadataChangeCallback.

func (*MockMetadataMockRecorder) Start

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

Start indicates an expected call of Start.

func (*MockMetadataMockRecorder) Stop

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

Stop indicates an expected call of Stop.

func (*MockMetadataMockRecorder) UnRegisterMetadataChangeCallback

func (mr *MockMetadataMockRecorder) UnRegisterMetadataChangeCallback(callbackId any) *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