go.temporal.io/server/common/api/metadata.go

249 LOC · 24 covered · 225 uncovered · 10 ranges · 139 concepts · 9 introducers · 60 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 api
2
3 import "strings"
4
5 type (
6 // Describes the scope of a method (whole cluster or inividual namespace).
7 Scope int32
8
9 // Describes what level of access is needed for a method. Note that this field is
10 // completely advisory. Any authorizer implementation may implement whatever logic it
11 // chooses, including ignoring this field. It is used by the "default" authorizer to check
12 // against roles in claims.
13 Access int32
14
15 // Describes if the method supports long-polled requests.
16 Polling int32
17
18 MethodMetadata struct {
19 // Describes the scope of a method (whole cluster or inividual namespace).
20 Scope Scope
21 // Describes what level of access is needed for a method (advisory).
22 Access Access
23 // Describes if long polling is supported by the method.
24 Polling Polling
25 }
26 )
27
28 const (
29 // Represents a missing Scope value.
30 ScopeUnknown Scope = iota
31 // Method affects a single namespace. The request message must contain a string field named "Namespace".
32 ScopeNamespace
33 // Method affects the whole cluster. The request message must _not_ contain any field named "Namespace".
34 ScopeCluster
35 )
36
37 const (
38 // Represents a missing Access value.
39 AccessUnknown Access = iota
40 // Method is read-only and should be accessible to readers.
41 AccessReadOnly
42 // Method is a normal write method.
43 AccessWrite
44 // Method is an administrative operation.
45 AccessAdmin
46 )
47
48 const (
49 // Represents a missing Polling value.
50 PollingUnknown Polling = iota
51 // Method isn't capable of long-polling.
52 PollingNone
53 // Method can optionally return long-polled responses.
54 PollingCapable
55 // Method responses are always long-polled.
56 PollingAlways
57 )
58
59 const (
60 WorkflowServicePrefix = "/temporal.api.workflowservice.v1.WorkflowService/"
61 OperatorServicePrefix = "/temporal.api.operatorservice.v1.OperatorService/"
62 HistoryServicePrefix = "/temporal.server.api.historyservice.v1.HistoryService/"
63 AdminServicePrefix = "/temporal.server.api.adminservice.v1.AdminService/"
64 MatchingServicePrefix = "/temporal.server.api.matchingservice.v1.MatchingService/"
65 // Technically not a gRPC service, but still using this format for metadata.
66 NexusServicePrefix = "/temporal.api.nexusservice.v1.NexusService/"
67 )
68
69 var (
70 workflowServiceMetadata = map[string]MethodMetadata{
71 "RegisterNamespace": {Scope: ScopeNamespace, Access: AccessAdmin, Polling: PollingNone},
72 "DescribeNamespace": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
73 "ListNamespaces": {Scope: ScopeCluster, Access: AccessReadOnly, Polling: PollingNone},
74 "UpdateNamespace": {Scope: ScopeNamespace, Access: AccessAdmin, Polling: PollingNone},
75 "DeprecateNamespace": {Scope: ScopeNamespace, Access: AccessAdmin, Polling: PollingNone},
76 "StartWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
77 "GetWorkflowExecutionHistory": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingCapable},
78 "GetWorkflowExecutionHistoryReverse": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
79 "PollWorkflowTaskQueue": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingAlways},
80 "RespondWorkflowTaskCompleted": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
81 "RespondWorkflowTaskFailed": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
82 "PollActivityTaskQueue": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingAlways},
83 "RecordActivityTaskHeartbeat": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
84 "RecordActivityTaskHeartbeatById": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
85 "RespondActivityTaskCompleted": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
86 "RespondActivityTaskCompletedById": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
87 "RespondActivityTaskFailed": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
88 "RespondActivityTaskFailedById": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
89 "RespondActivityTaskCanceled": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
90 "RespondActivityTaskCanceledById": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
91 "CountActivityExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
92 "CountNexusOperationExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
93 "DeleteActivityExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
94 "DeleteNexusOperationExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
95 "DescribeActivityExecution": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingCapable},
96 "DescribeNexusOperationExecution": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingCapable},
97 "PollActivityExecution": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingAlways},
98 "PollNexusOperationExecution": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingAlways},
99 "ListActivityExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
100 "ListNexusOperationExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
101 "RequestCancelActivityExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
102 "RequestCancelNexusOperationExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
103 "StartActivityExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
104 "StartNexusOperationExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
105 "TerminateActivityExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
106 "TerminateNexusOperationExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
107 "PollNexusTaskQueue": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingAlways},
108 "RespondNexusTaskCompleted": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
109 "RespondNexusTaskFailed": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
110 "RequestCancelWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
111 "SignalWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
112 "SignalWithStartWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
113 "ResetWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
114 "TerminateWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
115 "DeleteWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
116 "ListOpenWorkflowExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
117 "ListClosedWorkflowExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
118 "ListWorkflowExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
119 "ListArchivedWorkflowExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
120 "ScanWorkflowExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
121 "CountWorkflowExecutions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
122 "GetSearchAttributes": {Scope: ScopeCluster, Access: AccessReadOnly, Polling: PollingNone},
123 "RespondQueryTaskCompleted": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
124 "ResetStickyTaskQueue": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
125 "ShutdownWorker": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
126 "ExecuteMultiOperation": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
127 "QueryWorkflow": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
128 "DescribeWorkflowExecution": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
129 "DescribeTaskQueue": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
130 "GetClusterInfo": {Scope: ScopeCluster, Access: AccessReadOnly, Polling: PollingNone},
131 "GetSystemInfo": {Scope: ScopeCluster, Access: AccessReadOnly, Polling: PollingNone},
132 "ListTaskQueuePartitions": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
133 "CreateSchedule": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
134 "DescribeSchedule": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
135 "UpdateSchedule": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
136 "PatchSchedule": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
137 "ListScheduleMatchingTimes": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
138 "DeleteSchedule": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
139 "ListSchedules": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
140 "CountSchedules": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
141 "UpdateWorkerBuildIdCompatibility": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
142 "GetWorkerBuildIdCompatibility": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
143 "UpdateWorkerVersioningRules": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
144 "GetWorkerVersioningRules": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
145 "GetWorkerTaskReachability": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
146 "UpdateWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
147 "PollWorkflowExecutionUpdate": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingAlways},
148 "StartBatchOperation": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
149 "StopBatchOperation": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
150 "DescribeBatchOperation": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
151 "ListBatchOperations": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
152 "UpdateActivityOptions": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
153 "PauseActivity": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
154 "UnpauseActivity": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
155 "ResetActivity": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
156 "UpdateActivityExecutionOptions": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
157 "PauseActivityExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
158 "UnpauseActivityExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
159 "ResetActivityExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
160 "UpdateWorkflowExecutionOptions": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
161 "DescribeDeployment": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone}, // [cleanup-wv-pre-release]
162 "ListDeployments": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone}, // [cleanup-wv-pre-release]
163 "GetDeploymentReachability": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone}, // [cleanup-wv-pre-release]
164 "GetCurrentDeployment": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone}, // [cleanup-wv-pre-release]
165 "SetCurrentDeployment": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone}, // [cleanup-wv-pre-release]
166 "DescribeWorkerDeploymentVersion": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
167 "DescribeWorkerDeployment": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
168 "SetWorkerDeploymentCurrentVersion": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
169 "SetWorkerDeploymentRampingVersion": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
170 "SetWorkerDeploymentManager": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
171 "CreateWorkerDeployment": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
172 "DeleteWorkerDeployment": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
173 "CreateWorkerDeploymentVersion": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
174 "UpdateWorkerDeploymentVersionComputeConfig": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
175 "ValidateWorkerDeploymentVersionComputeConfig": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
176 "DeleteWorkerDeploymentVersion": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
177 "UpdateWorkerDeploymentVersionMetadata": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
178 "ListWorkerDeployments": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
179 "CreateWorkflowRule": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
180 "DescribeWorkflowRule": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
181 "DeleteWorkflowRule": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
182 "ListWorkflowRules": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
183 "TriggerWorkflowRule": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
184 "RecordWorkerHeartbeat": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
185 "ListWorkers": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
186 "CountWorkers": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
187 "DescribeWorker": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
188 "UpdateTaskQueueConfig": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
189 "FetchWorkerConfig": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
190 "UpdateWorkerConfig": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
191 "PauseWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
192 "UnpauseWorkflowExecution": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
193 }
194 operatorServiceMetadata = map[string]MethodMetadata{
195 "AddSearchAttributes": {Scope: ScopeNamespace, Access: AccessAdmin, Polling: PollingNone},
196 "RemoveSearchAttributes": {Scope: ScopeNamespace, Access: AccessAdmin, Polling: PollingNone},
197 "ListSearchAttributes": {Scope: ScopeNamespace, Access: AccessReadOnly, Polling: PollingNone},
198 "DeleteNamespace": {Scope: ScopeNamespace, Access: AccessAdmin, Polling: PollingNone},
199 "AddOrUpdateRemoteCluster": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
200 "RemoveRemoteCluster": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
201 "ListClusters": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
202 "CreateNexusEndpoint": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
203 "UpdateNexusEndpoint": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
204 "DeleteNexusEndpoint": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
205 "GetNexusEndpoint": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
206 "ListNexusEndpoints": {Scope: ScopeCluster, Access: AccessAdmin, Polling: PollingNone},
207 }
208 nexusServiceMetadata = map[string]MethodMetadata{
209 "DispatchNexusTask": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
210 "DispatchByNamespaceAndTaskQueue": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
211 "DispatchByEndpoint": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
212 "CompleteNexusOperation": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
213 "CompleteNexusOperationChasm": {Scope: ScopeNamespace, Access: AccessWrite, Polling: PollingNone},
214 }
215 )
216
217 // GetMethodMetadata gets metadata for a given API method in one of the services exported by
218 // frontend (WorkflowService, OperatorService, AdminService).
219 > func GetMethodMetadata(fullApiName string) MethodMetadata { metadata.go ×1
220 > switch {
221 > case strings.HasPrefix(fullApiName, WorkflowServicePrefix):
222 > return workflowServiceMetadata[MethodName(fullApiName)]
223 > case strings.HasPrefix(fullApiName, OperatorServicePrefix): metadata.go ×1
224 > return operatorServiceMetadata[MethodName(fullApiName)]
225 > case strings.HasPrefix(fullApiName, NexusServicePrefix): metadata.go ×2
226 > return nexusServiceMetadata[MethodName(fullApiName)]
227 > case strings.HasPrefix(fullApiName, AdminServicePrefix): metadata.go ×1
228 > return MethodMetadata{Scope: ScopeCluster, Access: AccessAdmin}
229 > default: metadata.go ×2
230 > return MethodMetadata{Scope: ScopeUnknown, Access: AccessUnknown}
231 }
232 }
233
234 // MethodName returns just the method name from a fully qualified name.
235 > func MethodName(fullApiName string) string { metadata.go ×1
236 > index := strings.LastIndex(fullApiName, "/")
237 > if index > -1 {
238 > return fullApiName[index+1:] metadata.go ×1
239 > }
240 > return fullApiName metadata.go ×1
241 }
242
243 > func ServiceName(fullApiName string) string { metadata.go ×1
244 > index := strings.LastIndex(fullApiName, "/")
245 > if index > -1 {
246 > return fullApiName[:index+1]
247 > }
248 > return "" metadata.go ×1
249 }