mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
72 lines
1.7 KiB
Go
72 lines
1.7 KiB
Go
package shard
|
|
|
|
import (
|
|
"context"
|
|
"sync/atomic"
|
|
|
|
"github.com/hanzoai/tasks/common/log"
|
|
"github.com/hanzoai/tasks/common/log/tag"
|
|
"github.com/hanzoai/tasks/common/pingable"
|
|
"github.com/hanzoai/tasks/common/primitives"
|
|
"github.com/hanzoai/tasks/service/history/configs"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
var Module = fx.Options(
|
|
fx.Provide(
|
|
ControllerProvider,
|
|
func(impl *ControllerImpl) Controller { return impl },
|
|
ContextFactoryProvider,
|
|
fx.Annotate(
|
|
func(p Controller) pingable.Pingable { return p },
|
|
fx.ResultTags(`group:"deadlockDetectorRoots"`),
|
|
),
|
|
),
|
|
ownershipBasedQuotaScalerModule,
|
|
)
|
|
|
|
var ownershipBasedQuotaScalerModule = fx.Options(
|
|
fx.Provide(func(
|
|
impl *ControllerImpl,
|
|
cfg *configs.Config,
|
|
) (*OwnershipBasedQuotaScalerImpl, error) {
|
|
return NewOwnershipBasedQuotaScaler(
|
|
impl,
|
|
int(cfg.NumberOfShards),
|
|
nil,
|
|
)
|
|
}),
|
|
fx.Provide(func(
|
|
impl *OwnershipBasedQuotaScalerImpl,
|
|
) OwnershipBasedQuotaScaler {
|
|
return impl
|
|
}),
|
|
fx.Provide(func() LazyLoadedOwnershipBasedQuotaScaler {
|
|
return LazyLoadedOwnershipBasedQuotaScaler{
|
|
Value: &atomic.Value{},
|
|
}
|
|
}),
|
|
fx.Invoke(initLazyLoadedOwnershipBasedQuotaScaler),
|
|
fx.Invoke(func(
|
|
lc fx.Lifecycle,
|
|
impl *OwnershipBasedQuotaScalerImpl,
|
|
) {
|
|
lc.Append(fx.Hook{
|
|
OnStop: func(_ context.Context) error {
|
|
impl.Close()
|
|
return nil
|
|
},
|
|
})
|
|
}),
|
|
)
|
|
|
|
func initLazyLoadedOwnershipBasedQuotaScaler(
|
|
serviceName primitives.ServiceName,
|
|
logger log.SnTaggedLogger,
|
|
ownershipBasedQuotaScaler OwnershipBasedQuotaScaler,
|
|
lazyLoadedOwnershipBasedQuotaScaler LazyLoadedOwnershipBasedQuotaScaler,
|
|
) {
|
|
lazyLoadedOwnershipBasedQuotaScaler.Store(ownershipBasedQuotaScaler)
|
|
logger.Info("Initialized lazy loaded OwnershipBasedQuotaScaler", tag.Service(serviceName))
|
|
}
|