mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Reject `RemoveRemoteCluster` (both the Operator and Admin gRPC paths) when any global namespace still lists the target cluster in its replication cluster set. ## Why? Removing a cluster that is still referenced by a global namespace leaves that namespace pointing at a cluster the registry no longer knows about, which breaks replication and namespace lookups until manually repaired. ## How did you test it? - [x] built - [x] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [ ] added new functional test(s)
54 lines
2.5 KiB
Go
54 lines
2.5 KiB
Go
//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination registry_mock.go
|
|
|
|
package namespace
|
|
|
|
import (
|
|
"go.temporal.io/server/common/pingable"
|
|
)
|
|
|
|
type (
|
|
// StateChangeCallbackFn can be registered to be called on any namespace state change or
|
|
// addition/removal from database, plus once for all namespaces after registration. There
|
|
// is no guarantee about when these are called.
|
|
StateChangeCallbackFn func(ns *Namespace, deletedFromDb bool)
|
|
|
|
// NamespaceStateChangedFn determines whether a namespace state change is significant enough
|
|
// to trigger callbacks. It can be overridden to add custom change detection logic.
|
|
NamespaceStateChangedFn func(currentClusterName string, oldNs *Namespace, newNs *Namespace) bool
|
|
|
|
// Registry provides access to Namespace objects by name or by ID.
|
|
Registry interface {
|
|
pingable.Pingable
|
|
GetNamespace(name Name) (*Namespace, error)
|
|
GetNamespaceWithOptions(name Name, opts GetNamespaceOptions) (*Namespace, error)
|
|
GetNamespaceByID(id ID) (*Namespace, error)
|
|
RefreshNamespaceById(namespaceId ID) (*Namespace, error)
|
|
GetNamespaceByIDWithOptions(id ID, opts GetNamespaceOptions) (*Namespace, error)
|
|
GetNamespaceID(name Name) (ID, error)
|
|
GetNamespaceName(id ID) (Name, error)
|
|
// GetAllNamespaces returns a snapshot of every namespace currently in the
|
|
// in-memory cache. May lag persistence by up to the configured refresh
|
|
// interval; not suitable for strongly-consistent reads.
|
|
GetAllNamespaces() []*Namespace
|
|
GetRegistrySize() (sizeOfCacheByName int64, sizeOfCacheByID int64)
|
|
// Registers callback for namespace state changes.
|
|
// StateChangeCallbackFn will be invoked for a new/deleted namespace or namespace that has
|
|
// State, ReplicationState, ActiveCluster, or isGlobalNamespace config changed.
|
|
RegisterStateChangeCallback(key any, cb StateChangeCallbackFn)
|
|
UnregisterStateChangeCallback(key any)
|
|
// GetCustomSearchAttributesMapper is a temporary solution to be able to get search attributes
|
|
// with from persistence if forceSearchAttributesCacheRefreshOnRead is true.
|
|
GetCustomSearchAttributesMapper(name Name) (CustomSearchAttributesMapper, error)
|
|
Start()
|
|
Stop()
|
|
}
|
|
|
|
GetNamespaceOptions struct {
|
|
// Setting this disables the readthrough logic, i.e. only looks at the current in-memory
|
|
// registry. This is useful if you want to avoid latency or avoid polluting the negative
|
|
// lookup cache. Note that you may get false negatives (namespace not found) if the
|
|
// namespace was created very recently.
|
|
DisableReadthrough bool
|
|
}
|
|
)
|