Files
tasks/common/dynamicconfig/shared_constants.go
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

103 lines
3.4 KiB
Go

package dynamicconfig
import (
"time"
"go.temporal.io/server/common/primitives"
)
const GlobalDefaultNumTaskQueuePartitions = 4
var defaultNumTaskQueuePartitions = []TypedConstrainedValue[int]{
// The per-ns worker task queue in all namespaces should only have one partition, since
// we'll only run one worker per task queue.
{
Constraints: Constraints{
TaskQueueName: primitives.PerNSWorkerTaskQueue,
},
Value: 1,
},
// The system activity worker task queues in the system local namespace should only have
// one partition, since we'll only run one worker per task queue.
{
Constraints: Constraints{
TaskQueueName: primitives.AddSearchAttributesActivityTQ,
Namespace: primitives.SystemLocalNamespace,
},
Value: 1,
},
{
Constraints: Constraints{
TaskQueueName: primitives.DeleteNamespaceActivityTQ,
Namespace: primitives.SystemLocalNamespace,
},
Value: 1,
},
{
Constraints: Constraints{
TaskQueueName: primitives.MigrationActivityTQ,
Namespace: primitives.SystemLocalNamespace,
},
Value: 1,
},
// TODO: After we have a solution for ensuring no tasks are lost, add a constraint here for
// all task queues in SystemLocalNamespace to have one partition.
// Default for everything else:
{
Value: GlobalDefaultNumTaskQueuePartitions,
},
}
var DefaultPerShardNamespaceRPSMax = GetIntPropertyFnFilteredByNamespace(0)
// params for controlling dynamic rate limiting options
type DynamicRateLimitingParams struct {
// Enabled toggles whether dynamic rate limiting is enabled.
Enabled bool
// RefreshInterval is how often the rate limit and dynamic properties are refreshed. Should
// be a string duratoin e.g. 10s even if the rate limiter is disabled, this property will
// still determine how often the dynamic config is reevaluated.
RefreshInterval time.Duration
// LatencyThreshold is the maximum average latency in ms before the rate limiter should
// backoff.
LatencyThreshold float64
// ErrorThreshold is the maximum ratio of errors:total_requests before the rate limiter
// Should backoff. Should be between 0 and 1.
ErrorThreshold float64
// RateBackoffStepSize is the amount the rate limit multiplier is reduced when backing off.
// Should be between 0 and 1
RateBackoffStepSize float64
// RateIncreaseStepSize is the amount the rate limit multiplier is increased when the
// system is healthy and current rate < max rate. Should be between 0 and 1.
RateIncreaseStepSize float64
// RateMultiMin is the minimum the rate limit multiplier can be reduced to.
RateMultiMin float64
// RateMultiMax is the maximum the rate limit multiplier can be increased to.
RateMultiMax float64
}
var DefaultDynamicRateLimitingParams = DynamicRateLimitingParams{
Enabled: false,
RefreshInterval: 10 * time.Second,
LatencyThreshold: 0.0, // will not do backoff based on latency
ErrorThreshold: 0.0, // will not do backoff based on errors
RateBackoffStepSize: 0.3,
RateIncreaseStepSize: 0.1,
RateMultiMin: 0.8,
RateMultiMax: 1.0,
}
type CircuitBreakerSettings struct {
// MaxRequests: Maximum number of requests allowed to pass through when
// it is in half-open state (default 1).
MaxRequests int
// Interval: Cyclic period in closed state to clear the internal counts;
// if interval is 0, then it never clears the internal counts (default 0).
Interval time.Duration
// Timeout: Period of open state before changing to half-open state (default 60s).`
Timeout time.Duration
}