mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +00:00
## What changed? <!-- Describe what has changed in this PR --> allow passive to generate replication tasks We skip active on cluster check before generating replication tasks ## Why? <!-- Tell your future self why have you made these changes --> ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) -->
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package api
|
|
|
|
import (
|
|
"github.com/pborman/uuid"
|
|
"go.temporal.io/api/serviceerror"
|
|
"go.temporal.io/server/common/namespace"
|
|
historyi "go.temporal.io/server/service/history/interfaces"
|
|
)
|
|
|
|
func GetActiveNamespace(
|
|
shard historyi.ShardContext,
|
|
namespaceUUID namespace.ID,
|
|
) (*namespace.Namespace, error) {
|
|
|
|
err := ValidateNamespaceUUID(namespaceUUID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
namespaceEntry, err := shard.GetNamespaceRegistry().GetNamespaceByID(namespaceUUID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !namespaceEntry.ActiveInCluster(shard.GetClusterMetadata().GetCurrentClusterName()) {
|
|
return nil, serviceerror.NewNamespaceNotActive(
|
|
namespaceEntry.Name().String(),
|
|
shard.GetClusterMetadata().GetCurrentClusterName(),
|
|
namespaceEntry.ActiveClusterName())
|
|
}
|
|
return namespaceEntry, nil
|
|
}
|
|
|
|
func GetNamespace(
|
|
shard historyi.ShardContext,
|
|
namespaceUUID namespace.ID,
|
|
) (*namespace.Namespace, error) {
|
|
|
|
err := ValidateNamespaceUUID(namespaceUUID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
namespaceEntry, err := shard.GetNamespaceRegistry().GetNamespaceByID(namespaceUUID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return namespaceEntry, nil
|
|
}
|
|
|
|
func ValidateNamespaceUUID(
|
|
namespaceUUID namespace.ID,
|
|
) error {
|
|
if namespaceUUID == "" {
|
|
return serviceerror.NewInvalidArgument("Missing namespace UUID.")
|
|
} else if uuid.Parse(namespaceUUID.String()) == nil {
|
|
return serviceerror.NewInvalidArgument("Invalid namespace UUID.")
|
|
}
|
|
return nil
|
|
}
|