mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Replaced the remaining `WithFxOptionsForService` decorations in `tests/xdc/history_replication_dlq_test.go` with focused test hooks. ## Why? This removes another unrestricted Fx escape hatch from xdc functional tests as part of moving away from duplicated onebox setup.
50 lines
1.8 KiB
Go
50 lines
1.8 KiB
Go
package testhooks
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
persistencespb "go.temporal.io/server/api/persistence/v1"
|
|
replicationspb "go.temporal.io/server/api/replication/v1"
|
|
"go.temporal.io/server/common/namespace"
|
|
)
|
|
|
|
// Test hook keys with their return type and scope.
|
|
// Try to avoid global scope as it requires a dedicated test cluster.
|
|
var (
|
|
MatchingDisableSyncMatch = newKey[bool, namespace.ID]()
|
|
MatchingLBForceReadPartition = newKey[int, namespace.ID]()
|
|
MatchingLBForceWritePartition = newKey[int, namespace.ID]()
|
|
UpdateWithStartInBetweenLockAndStart = newKey[func(), namespace.ID]()
|
|
UpdateWithStartOnClosingWorkflowRetry = newKey[func(), namespace.ID]()
|
|
TaskQueuesInDeploymentSyncBatchSize = newKey[int, global]()
|
|
MatchingIgnoreRoutingConfigRevisionCheck = newKey[bool, namespace.ID]()
|
|
MatchingDeploymentRegisterErrorBackoff = newKey[time.Duration, namespace.ID]()
|
|
MatchingForwardTaskDelay = newKey[time.Duration, namespace.ID]()
|
|
HistoryReplicationTaskInterceptor = newKey[func(*replicationspb.ReplicationTask, func() error) error, global]()
|
|
HistoryReplicationDLQWriteInterceptor = newKey[func(*persistencespb.ReplicationTaskInfo, func() error) error, global]()
|
|
NamespaceReplicationTaskInterceptor = newKey[func(context.Context, *replicationspb.NamespaceTaskAttributes, func() error) error, namespace.Name]()
|
|
)
|
|
|
|
// keyID is a unique identifier for a key, used as a map key.
|
|
type keyID = int64
|
|
|
|
// global is the scope type for global hooks.
|
|
type global struct{}
|
|
|
|
// GlobalScope is the singleton value for global hooks.
|
|
var GlobalScope = global{}
|
|
|
|
// ScopeType indicates the scope of a hook at runtime.
|
|
type ScopeType int
|
|
|
|
const (
|
|
ScopeNamespace ScopeType = iota
|
|
ScopeGlobal
|
|
)
|
|
|
|
type Key[T any, S any] struct {
|
|
id keyID
|
|
scopeType ScopeType
|
|
}
|