Files
tasks/service/history/circuitbreakerpool/fx.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

53 lines
1.7 KiB
Go

package circuitbreakerpool
import (
"fmt"
"github.com/hanzoai/tasks/common/circuitbreaker"
"github.com/hanzoai/tasks/common/namespace"
"github.com/hanzoai/tasks/service/history/configs"
"github.com/hanzoai/tasks/service/history/tasks"
"go.uber.org/fx"
)
var Module = fx.Options(
fx.Provide(OutboundQueueCircuitBreakerPoolProvider),
)
type OutboundQueueCircuitBreakerPool struct {
*CircuitBreakerPool[tasks.TaskGroupNamespaceIDAndDestination]
}
func OutboundQueueCircuitBreakerPoolProvider(
namespaceRegistry namespace.Registry,
config *configs.Config,
) *OutboundQueueCircuitBreakerPool {
return &OutboundQueueCircuitBreakerPool{
CircuitBreakerPool: NewCircuitBreakerPool(
func(key tasks.TaskGroupNamespaceIDAndDestination) circuitbreaker.TwoStepCircuitBreaker {
// This is intentionally not failing the function in case of error. The circuit breaker is
// agnostic to Task implementation, and thus the settings function is not expected to return
// an error. Also, in this case, if the namespace registry fails to get the name, then the
// task itself will fail when it is processed and tries to get the namespace name.
nsName, _ := namespaceRegistry.GetNamespaceName(namespace.ID(key.NamespaceID))
cb := circuitbreaker.NewTwoStepCircuitBreakerWithDynamicSettings(circuitbreaker.Settings{
Name: fmt.Sprintf(
"circuit_breaker:%s:%s:%s",
key.TaskGroup,
key.NamespaceID,
key.Destination,
),
})
initial, cancel := config.OutboundQueueCircuitBreakerSettings(
nsName.String(),
key.Destination,
cb.UpdateSettings,
)
cb.UpdateSettings(initial)
_ = cancel // OnceMap never deletes anything. use this if we support deletion
return cb
},
),
}
}