Files
Alex ShtinandGitHub 8e8f1b0f7c Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00

207 lines
7.1 KiB
Go

package client
import (
"time"
"go.opentelemetry.io/otel/trace"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/config"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/persistence/cassandra"
"go.temporal.io/server/common/persistence/faultinjection"
"go.temporal.io/server/common/persistence/serialization"
"go.temporal.io/server/common/persistence/sql"
"go.temporal.io/server/common/persistence/telemetry"
"go.temporal.io/server/common/primitives"
"go.temporal.io/server/common/quotas"
"go.temporal.io/server/common/resolver"
otel "go.temporal.io/server/common/telemetry"
"go.uber.org/fx"
)
type (
PersistenceMaxQps dynamicconfig.IntPropertyFn
PersistenceNamespaceMaxQps dynamicconfig.IntPropertyFnWithNamespaceFilter
PersistencePerShardNamespaceMaxQPS dynamicconfig.IntPropertyFnWithNamespaceFilter
OperatorRPSRatio dynamicconfig.FloatPropertyFn
PersistenceBurstRatio dynamicconfig.FloatPropertyFn
DynamicRateLimitingParams dynamicconfig.TypedPropertyFn[dynamicconfig.DynamicRateLimitingParams]
ClusterName string
NewFactoryParams struct {
fx.In
DataStoreFactory persistence.DataStoreFactory
EventBlobCache persistence.XDCCache
Cfg *config.Persistence
PersistenceMaxQPS PersistenceMaxQps
PersistenceNamespaceMaxQPS PersistenceNamespaceMaxQps
PersistencePerShardNamespaceMaxQPS PersistencePerShardNamespaceMaxQPS
OperatorRPSRatio OperatorRPSRatio
PersistenceBurstRatio PersistenceBurstRatio
ClusterName ClusterName
ServiceName primitives.ServiceName
MetricsHandler metrics.Handler
Logger log.Logger
HealthSignals persistence.HealthSignalAggregator
DynamicRateLimitingParams DynamicRateLimitingParams
}
FactoryProviderFn func(NewFactoryParams) Factory
)
var Module = fx.Options(
fx.Provide(DataStoreFactoryProvider),
fx.Invoke(DataStoreFactoryLifetimeHooks),
fx.Provide(managerProvider(Factory.NewClusterMetadataManager)),
fx.Provide(managerProvider(Factory.NewMetadataManager)),
fx.Provide(managerProvider(Factory.NewTaskManager)),
fx.Provide(managerProvider(Factory.NewNamespaceReplicationQueue)),
fx.Provide(managerProvider(Factory.NewShardManager)),
fx.Provide(managerProvider(Factory.NewExecutionManager)),
fx.Provide(managerProvider(Factory.NewHistoryTaskQueueManager)),
fx.Provide(managerProvider(Factory.NewNexusEndpointManager)),
fx.Provide(ClusterNameProvider),
fx.Provide(HealthSignalAggregatorProvider),
fx.Provide(persistence.NewDLQMetricsEmitter),
fx.Provide(EventBlobCacheProvider),
)
func ClusterNameProvider(config *cluster.Config) ClusterName {
return ClusterName(config.CurrentClusterName)
}
func EventBlobCacheProvider(
dc *dynamicconfig.Collection,
logger log.Logger,
) persistence.XDCCache {
return persistence.NewEventsBlobCache(
dynamicconfig.XDCCacheMaxSizeBytes.Get(dc)(),
20*time.Second,
logger,
)
}
func FactoryProvider(
params NewFactoryParams,
) Factory {
var systemRequestRateLimiter, namespaceRequestRateLimiter, shardRequestRateLimiter quotas.RequestRateLimiter
if params.PersistenceMaxQPS != nil && params.PersistenceMaxQPS() > 0 {
systemRequestRateLimiter = NewPriorityRateLimiter(
params.PersistenceMaxQPS,
RequestPriorityFn,
params.OperatorRPSRatio,
params.PersistenceBurstRatio,
params.HealthSignals,
params.DynamicRateLimitingParams,
params.MetricsHandler,
params.Logger,
)
namespaceRequestRateLimiter = NewPriorityNamespaceRateLimiter(
params.PersistenceMaxQPS,
params.PersistenceNamespaceMaxQPS,
RequestPriorityFn,
params.OperatorRPSRatio,
params.PersistenceBurstRatio,
)
shardRequestRateLimiter = NewPriorityNamespaceShardRateLimiter(
params.PersistenceMaxQPS,
params.PersistencePerShardNamespaceMaxQPS,
RequestPriorityFn,
params.OperatorRPSRatio,
params.PersistenceBurstRatio,
)
}
return NewFactory(
params.DataStoreFactory,
params.Cfg,
systemRequestRateLimiter,
namespaceRequestRateLimiter,
shardRequestRateLimiter,
serialization.NewSerializer(),
params.EventBlobCache,
string(params.ClusterName),
params.MetricsHandler,
params.Logger,
params.HealthSignals,
)
}
func HealthSignalAggregatorProvider(
dynamicCollection *dynamicconfig.Collection,
metricsHandler metrics.Handler,
logger log.ThrottledLogger,
) persistence.HealthSignalAggregator {
if dynamicconfig.PersistenceHealthSignalMetricsEnabled.Get(dynamicCollection)() {
return persistence.NewHealthSignalAggregatorImpl(
dynamicconfig.PersistenceHealthSignalAggregationEnabled.Get(dynamicCollection)(),
dynamicconfig.PersistenceHealthSignalWindowSize.Get(dynamicCollection)(),
dynamicconfig.PersistenceHealthSignalBufferSize.Get(dynamicCollection)(),
metricsHandler,
dynamicconfig.ShardRPSWarnLimit.Get(dynamicCollection),
dynamicconfig.ShardPerNsRPSWarnPercent.Get(dynamicCollection),
logger,
)
}
return persistence.NoopHealthSignalAggregator
}
func DataStoreFactoryProvider(
clusterName ClusterName,
r resolver.ServiceResolver,
cfg *config.Persistence,
abstractDataStoreFactory AbstractDataStoreFactory,
logger log.Logger,
metricsHandler metrics.Handler,
tracerProvider trace.TracerProvider,
) persistence.DataStoreFactory {
var dataStoreFactory persistence.DataStoreFactory
defaultStoreCfg := cfg.DataStores[cfg.DefaultStore]
switch {
case defaultStoreCfg.Cassandra != nil:
dataStoreFactory = cassandra.NewFactory(*defaultStoreCfg.Cassandra, r, string(clusterName), logger, metricsHandler)
case defaultStoreCfg.SQL != nil:
dataStoreFactory = sql.NewFactory(*defaultStoreCfg.SQL, r, string(clusterName), logger, metricsHandler)
case defaultStoreCfg.CustomDataStoreConfig != nil:
dataStoreFactory = abstractDataStoreFactory.NewFactory(*defaultStoreCfg.CustomDataStoreConfig, r, string(clusterName), logger, metricsHandler)
default:
logger.Fatal("invalid config: one of cassandra or sql params must be specified for default data store")
}
if defaultStoreCfg.FaultInjection != nil {
dataStoreFactory = faultinjection.NewFaultInjectionDatastoreFactory(defaultStoreCfg.FaultInjection, dataStoreFactory)
}
tracer := tracerProvider.Tracer(otel.ComponentPersistence)
if otel.IsEnabled(tracer) {
dataStoreFactory = telemetry.NewTelemetryDataStoreFactory(dataStoreFactory, logger, tracer)
}
return dataStoreFactory
}
func DataStoreFactoryLifetimeHooks(lc fx.Lifecycle, f persistence.DataStoreFactory) {
lc.Append(fx.StopHook(f.Close))
}
func managerProvider[T persistence.Closeable](newManagerFn func(Factory) (T, error)) func(Factory, fx.Lifecycle) (T, error) {
return func(f Factory, lc fx.Lifecycle) (T, error) {
manager, err := newManagerFn(f) // passing receiver (Factory) as first argument.
if err != nil {
var nilT T
return nilT, err
}
lc.Append(fx.StopHook(manager.Close))
return manager, nil
}
}