go.temporal.io/server/components/nexusoperations/config.go

225 LOC · 23 covered · 202 uncovered · 4 ranges · 118 concepts · 4 introducers · 34 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package nexusoperations
2
3 import (
4 "strings"
5 "time"
6
7 chasmnexus "go.temporal.io/server/chasm/lib/nexusoperation"
8 "go.temporal.io/server/common/backoff"
9 "go.temporal.io/server/common/config"
10 "go.temporal.io/server/common/dynamicconfig"
11 "go.temporal.io/server/common/headers"
12 "go.temporal.io/server/common/rpc/interceptor"
13 )
14
15 var RequestTimeout = dynamicconfig.NewDestinationDurationSetting(
16 "component.nexusoperations.request.timeout",
17 time.Second*10,
18 `RequestTimeout is the timeout for making a single nexus start or cancel request.`,
19 )
20
21 var MinRequestTimeout = dynamicconfig.NewNamespaceDurationSetting(
22 "component.nexusoperations.limit.request.timeout.min",
23 time.Millisecond*1500,
24 `MinRequestTimeout is the minimum time remaining for a request to complete for the server to make
25 RPCs. If the remaining request timeout is less than this value, a non-retryable timeout error will be returned.`,
26 )
27
28 var MinDispatchTaskTimeout = dynamicconfig.NewNamespaceDurationSetting(
29 "component.nexusoperations.limit.dispatch.task.timeout.min",
30 time.Second,
31 `MinDispatchTaskTimeout is the minimum time remaining for a request to be dispatched to the handler worker.
32 If the remaining request timeout is less than this value, a timeout error will be returned. Working in conjunction with
33 MinRequestTimeout, both configs help ensure that the server has enough time to complete a Nexus request.`,
34 )
35
36 var MaxConcurrentOperations = dynamicconfig.NewNamespaceIntSetting(
37 "component.nexusoperations.limit.operation.concurrency",
38 // Temporary limit due to a persistence limitation, this will be increased when we change persistence to accept
39 // partial sub state machine updates.
40 30,
41 `MaxConcurrentOperations limits the maximum allowed concurrent Nexus Operations for a given workflow execution.
42 Once the limit is reached, ScheduleNexusOperation commands will be rejected.`,
43 )
44
45 var MaxServiceNameLength = dynamicconfig.NewNamespaceIntSetting(
46 "component.nexusoperations.limit.service.name.length",
47 1000,
48 `MaxServiceNameLength limits the maximum allowed length for a Nexus Service name.
49 ScheduleNexusOperation commands with a service name that exceeds this limit will be rejected.
50 Uses Go's len() function to determine the length.`,
51 )
52
53 var MaxOperationNameLength = dynamicconfig.NewNamespaceIntSetting(
54 "component.nexusoperations.limit.operation.name.length",
55 1000,
56 `MaxOperationNameLength limits the maximum allowed length for a Nexus Operation name.
57 ScheduleNexusOperation commands with an operation name that exceeds this limit will be rejected.
58 Uses Go's len() function to determine the length.`,
59 )
60
61 var MaxOperationTokenLength = dynamicconfig.NewNamespaceIntSetting(
62 "component.nexusoperations.limit.operation.token.length",
63 4096,
64 `Limits the maximum allowed length for a Nexus Operation token. Tokens returned via start responses or via async
65 completions that exceed this limit will be rejected. Uses Go's len() function to determine the length.
66 Leave this limit long enough to fit a workflow ID and namespace name plus padding at minimum since that's what the SDKs
67 use as the token.`,
68 )
69
70 var MaxOperationHeaderSize = dynamicconfig.NewNamespaceIntSetting(
71 "component.nexusoperations.limit.header.size",
72 8192,
73 `The maximum allowed header size for a Nexus Operation.
74 ScheduleNexusOperation commands with a "nexus_header" field that exceeds this limit will be rejected.
75 Uses Go's len() function on header keys and values to determine the total size.`,
76 )
77
78 var UseSystemCallbackURL = dynamicconfig.NewGlobalBoolSetting(
79 "component.nexusoperations.useSystemCallbackURL",
80 true,
81 `UseSystemCallbackURL is a global feature toggle that controls how the executor generates
82 callback URLs for worker targets in Nexus Operations.When set to true,
83 the executor will use the fixed system callback URL ("temporal://system") for all worker targets,
84 instead of generating URLs from the callback URL template.
85 This simplifies configuration and improves reliability for worker callbacks.
86 - false: The executor uses the callback URL template to generate callback URLs for worker targets.
87 - true (default): The executor uses the fixed system callback URL ("temporal://system") for worker targets.
88 Note: The default will switch to true in future releases.`,
89 )
90
91 var DisallowedOperationHeaders = dynamicconfig.NewGlobalTypedSettingWithConverter(
92 "component.nexusoperations.disallowedHeaders",
93 func(in any) ([]string, error) {
94 keys, err := dynamicconfig.ConvertStructure[[]string](nil)(in)
95 if err != nil {
96 return nil, err
97 }
98 for i, k := range keys {
99 keys[i] = strings.ToLower(k)
100 }
101 return keys, nil
102 },
103 []string{
104 "request-timeout",
105 interceptor.DCRedirectionAPIHeaderName,
106 interceptor.DCRedirectionSourceCellHeaderName,
107 interceptor.DCRedirectionContextHeaderName,
108 headers.CallerNameHeaderName,
109 headers.CallerTypeHeaderName,
110 headers.CallOriginHeaderName,
111 headers.PrincipalTypeHeaderName,
112 headers.PrincipalNameHeaderName,
113 },
114 `Case insensitive list of disallowed header keys for Nexus Operations.
115 ScheduleNexusOperation commands with a "nexus_header" field that contains any of these disallowed keys will be
116 rejected.`,
117 )
118
119 var MaxOperationScheduleToCloseTimeout = dynamicconfig.NewNamespaceDurationSetting(
120 "component.nexusoperations.limit.scheduleToCloseTimeout",
121 0,
122 `MaxOperationScheduleToCloseTimeout limits the maximum allowed duration of a Nexus Operation. ScheduleOperation
123 commands that specify no schedule-to-close timeout or a longer timeout than permitted will have their
124 schedule-to-close timeout capped to this value. 0 implies no limit.`,
125 )
126
127 var CallbackURLTemplate = dynamicconfig.NewGlobalStringSetting(
128 "component.nexusoperations.callback.endpoint.template",
129 "unset",
130 `Controls the template for generating callback URLs included in Nexus operation requests, which are used to deliver asynchronous completion.
131 The template can be used to interpolate the {{.NamepaceName}} and {{.NamespaceID}} parameters to construct a publicly accessible URL.
132 Must be set in order to use Nexus Operations.`,
133 )
134
135 var RetryPolicyInitialInterval = dynamicconfig.NewGlobalDurationSetting(
136 "component.nexusoperations.retryPolicy.initialInterval",
137 time.Second,
138 `The initial backoff interval between every nexus StartOperation or CancelOperation request for a given operation.`,
139 )
140
141 var RetryPolicyMaximumInterval = dynamicconfig.NewGlobalDurationSetting(
142 "component.nexusoperations.retryPolicy.maxInterval",
143 time.Hour,
144 `The maximum backoff interval between every nexus StartOperation or CancelOperation request for a given operation.`,
145 )
146
147 var MetricTagConfiguration = dynamicconfig.NewGlobalTypedSetting(
148 "component.nexusoperations.metrics.tags",
149 chasmnexus.NexusMetricTagConfig{},
150 `Controls which metric tags are included with Nexus operation metrics. This configuration supports:
151 1. Service name tag - adds the Nexus service name as a metric dimension (IncludeServiceTag). Used by callers and handlers.
152 2. Operation name tag - adds the Nexus operation name as a metric dimension (IncludeOperationTag). Used by callers and handlers.
153 3. Header-based tags - maps values from request headers to metric tags (HeaderTagMappings). Only used by handlers.
154
155 Note: default metric tags (like namespace, endpoint) are always included and not affected by this configuration.
156 Adding high-cardinality tags (like unique operation names) can significantly increase metric storage
157 requirements and query complexity. Consider the cardinality impact when enabling these tags.`,
158 )
159
160 var RecordCancelRequestCompletionEvents = dynamicconfig.NewGlobalBoolSetting(
161 "component.nexusoperations.recordCancelRequestCompletionEvents",
162 true,
163 `Boolean flag to control whether to record NexusOperationCancelRequestCompleted and
164 NexusOperationCancelRequestFailed events. Default true.`,
165 )
166
167 type Config struct {
168 NumHistoryShards int32
169 RequestTimeout dynamicconfig.DurationPropertyFnWithDestinationFilter
170 MinRequestTimeout dynamicconfig.DurationPropertyFnWithNamespaceFilter
171 MaxConcurrentOperations dynamicconfig.IntPropertyFnWithNamespaceFilter
172 MaxServiceNameLength dynamicconfig.IntPropertyFnWithNamespaceFilter
173 MaxOperationNameLength dynamicconfig.IntPropertyFnWithNamespaceFilter
174 MaxOperationTokenLength dynamicconfig.IntPropertyFnWithNamespaceFilter
175 MaxOperationHeaderSize dynamicconfig.IntPropertyFnWithNamespaceFilter
176 DisallowedOperationHeaders dynamicconfig.TypedPropertyFn[[]string]
177 MaxOperationScheduleToCloseTimeout dynamicconfig.DurationPropertyFnWithNamespaceFilter
178 PayloadSizeLimit dynamicconfig.IntPropertyFnWithNamespaceFilter
179 CallbackURLTemplate dynamicconfig.StringPropertyFn
180 UseSystemCallbackURL dynamicconfig.BoolPropertyFn
181 UseNewFailureWireFormat dynamicconfig.BoolPropertyFnWithNamespaceFilter
182 RecordCancelRequestCompletionEvents dynamicconfig.BoolPropertyFn
183 MetricTagConfig dynamicconfig.TypedPropertyFn[chasmnexus.NexusMetricTagConfig]
184 RetryPolicy func() backoff.RetryPolicy
185 }
186
187 > func ConfigProvider(dc *dynamicconfig.Collection, cfg *config.Persistence) *Config { fx.go ×44
188 > return &Config{
189 > RequestTimeout: RequestTimeout.Get(dc),
190 > MinRequestTimeout: MinRequestTimeout.Get(dc),
191 > MaxConcurrentOperations: MaxConcurrentOperations.Get(dc),
192 > MaxServiceNameLength: MaxServiceNameLength.Get(dc),
193 > MaxOperationNameLength: MaxOperationNameLength.Get(dc),
194 > MaxOperationTokenLength: MaxOperationTokenLength.Get(dc),
195 > MaxOperationHeaderSize: MaxOperationHeaderSize.Get(dc),
196 > DisallowedOperationHeaders: DisallowedOperationHeaders.Get(dc),
197 > MaxOperationScheduleToCloseTimeout: MaxOperationScheduleToCloseTimeout.Get(dc),
198 > PayloadSizeLimit: dynamicconfig.BlobSizeLimitError.Get(dc),
199 > CallbackURLTemplate: CallbackURLTemplate.Get(dc),
200 > UseSystemCallbackURL: UseSystemCallbackURL.Get(dc),
201 > UseNewFailureWireFormat: chasmnexus.UseNewFailureWireFormat.Get(dc),
202 > RecordCancelRequestCompletionEvents: RecordCancelRequestCompletionEvents.Get(dc),
203 > MetricTagConfig: MetricTagConfiguration.Get(dc),
204 > RetryPolicy: func() backoff.RetryPolicy {
205 return backoff.NewExponentialRetryPolicy(
206 RetryPolicyInitialInterval.Get(dc)(),
207 ).WithMaximumInterval(
208 RetryPolicyMaximumInterval.Get(dc)(),
209 ).WithExpirationInterval(
210 backoff.NoInterval,
211 )
212 },
213 NumHistoryShards: cfg.NumHistoryShards,
214 }
215 }
216
217 // ResolvedMetricTagConfig returns the configured metric tag config, defaulting to an empty config
218 // when the receiver or the setting is nil (e.g. in tests that construct a bare Config). It is
219 // nil-receiver safe.
220 > func (c *Config) ResolvedMetricTagConfig() chasmnexus.NexusMetricTagConfig { metrics.go ×3
221 > if c == nil || c.MetricTagConfig == nil {
222 > return chasmnexus.NexusMetricTagConfig{} config.go ×1
223 > }
224 > return c.MetricTagConfig() metrics.go ×2
225 }