Files
tasks/common/worker_versioning/version_reactivation_signal_cache.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

66 lines
1.9 KiB
Go

//nolint:staticcheck
package worker_versioning
import (
"github.com/hanzoai/tasks/common/cache"
"github.com/hanzoai/tasks/common/metrics"
)
// ReactivationSignalCache deduplicates reactivation signals to version workflows.
//
// Implementations are expected to be safe for concurrent use.
type (
ReactivationSignalCache interface {
// ShouldSendSignal returns true if signal should be sent (not recently sent)
// and atomically marks it as sent. Returns false if recently sent.
ShouldSendSignal(namespaceID, deploymentName, buildID string) bool
}
reactivationSignalCacheKey struct {
namespaceID string
deploymentName string
buildID string
}
ReactivationSignalCacheImpl struct {
cache.Cache
metricsHandler metrics.Handler
}
)
// NewReactivationSignalCache wraps the provided cache with a typed API and metrics.
func NewReactivationSignalCache(c cache.Cache, metricsHandler metrics.Handler) ReactivationSignalCache {
h := metricsHandler.WithTags(metrics.CacheTypeTag(metrics.VersionReactivationSignalCacheTypeTagValue))
return &ReactivationSignalCacheImpl{
Cache: c,
metricsHandler: h,
}
}
func (c *ReactivationSignalCacheImpl) ShouldSendSignal(
namespaceID, deploymentName, buildID string,
) bool {
handler := c.metricsHandler.WithTags(
metrics.OperationTag(metrics.VersionReactivationSignalCacheShouldSendScope),
metrics.NamespaceIDTag(namespaceID),
)
metrics.CacheRequests.With(handler).Record(1)
key := reactivationSignalCacheKey{
namespaceID: namespaceID,
deploymentName: deploymentName,
buildID: buildID,
}
// Check if we recently sent a signal for this version
if c.Cache.Get(key) != nil {
// Entry exists, signal was recently sent - deduplicate
return false
}
// No recent signal, mark as sent and return true
metrics.CacheMissCounter.With(handler).Record(1)
c.Cache.Put(key, true)
return true
}