workflow.go ×10

Frontier kind: Code frontier

unlabeled · c_40a004de68d8

9 tests · 2042 LOC · 81 files · introduces 0 tests · 69 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges69 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
310 ranges2042 lines · 81 files · Browse complete extent
All tests (intent)
9 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

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 native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 69 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/deletenamespace/deleteexecutions/workflow.go 65 introduced LOC · 10 ranges

Open complete file

73 )
74
75 > func validateParams(ctx workflow.Context, params *DeleteExecutionsParams) error { workflow.go
76 > if params.NamespaceID.IsEmpty() {
77 return errors.NewInvalidArgument("namespace ID is required", nil)
78 }
79 > if params.Namespace.IsEmpty() { workflow.go
80 return errors.NewInvalidArgument("namespace is required", nil)
81 }
82 > if params.FirstRunStartTime.IsZero() { workflow.go
83 params.FirstRunStartTime = workflow.Now(ctx).UTC()
84 }
85 > params.Config.ApplyDefaults() workflow.go
86 > return nil
87 }
88
89 > func DeleteExecutionsWorkflow(ctx workflow.Context, params DeleteExecutionsParams) (DeleteExecutionsResult, error) { workflow.go
90 > logger := log.With(
91 > workflow.GetLogger(ctx),
92 > tag.WorkflowType(WorkflowName),
93 > tag.WorkflowNamespace(params.Namespace.String()),
94 > tag.WorkflowNamespaceID(params.NamespaceID.String()))
95 >
96 > logger.Info("Workflow started.")
97 > result := DeleteExecutionsResult{
98 > SuccessCount: params.PreviousSuccessCount,
99 > ErrorCount: params.PreviousErrorCount,
100 > }
101 >
102 > if err := validateParams(ctx, &params); err != nil {
103 return result, err
104 }
105 > logger.Info("Effective config.", tag.Value(params.Config.String())) workflow.go
106 >
107 > if err := workflow.SetQueryHandler(ctx, StatsQuery, func() (DeleteExecutionsStats, error) {
108 now := workflow.Now(ctx).UTC()
109 des := DeleteExecutionsStats{
129 }
130
131 > var a *Activities workflow.go
132 > var la *LocalActivities
133 >
134 > ctx = workflow.WithTaskQueue(ctx, primitives.DeleteNamespaceActivityTQ)
135 >
136 > nextPageToken := params.NextPageToken
137 > runningDeleteExecutionsActivityCount := 0
138 > runningDeleteExecutionsSelector := workflow.NewSelector(ctx)
139 > var lastDeleteExecutionsActivityErr error
140 >
141 > // Two activities DeleteExecutionsActivity and GetNextPageTokenActivity are executed here essentially in reverse order
142 > // because Get is called immediately for GetNextPageTokenActivity but not for DeleteExecutionsActivity.
143 > // These activities scan visibility storage independently but GetNextPageTokenActivity considered to be quick and can be done synchronously.
144 > // It reads nextPageToken and pass it DeleteExecutionsActivity. This allocates block of workflow executions to delete for
145 > // DeleteExecutionsActivity which takes much longer to complete. This is why this workflow starts
146 > // ConcurrentDeleteExecutionsActivities number of them and executes them concurrently on available workers.
147 > for i := 0; i < params.Config.PagesPerExecution; i++ {
148 > ctx1 := workflow.WithActivityOptions(ctx, deleteWorkflowExecutionsActivityOptions)
149 > deleteExecutionsFuture := workflow.ExecuteActivity(ctx1, a.DeleteExecutionsActivity, &DeleteExecutionsActivityParams{
150 > Namespace: params.Namespace,
151 > NamespaceID: params.NamespaceID,
152 > RPS: params.Config.DeleteActivityRPS,
153 > ListPageSize: params.Config.PageSize,
154 > NextPageToken: nextPageToken,
155 > })
156 >
157 > ctx2 := workflow.WithLocalActivityOptions(ctx, localActivityOptions)
158 > err := workflow.ExecuteLocalActivity(ctx2, la.GetNextPageTokenActivity, GetNextPageTokenParams{
159 > NamespaceID: params.NamespaceID,
160 > Namespace: params.Namespace,
161 > PageSize: params.Config.PageSize,
162 > NextPageToken: nextPageToken,
163 > }).Get(ctx, &nextPageToken)
164 > if err != nil {
165 return result, err
166 }
167
168 > runningDeleteExecutionsActivityCount++ workflow.go
169 > runningDeleteExecutionsSelector.AddFuture(deleteExecutionsFuture, func(f workflow.Future) {
170 > runningDeleteExecutionsActivityCount--
171 > var der DeleteExecutionsActivityResult
172 > deErr := f.Get(ctx, &der)
173 > if deErr != nil {
174 lastDeleteExecutionsActivityErr = deErr
175 return
179 })
180
181 > if runningDeleteExecutionsActivityCount >= params.Config.ConcurrentDeleteExecutionsActivities { workflow.go
182 // Wait for one of running activities to complete.
183 runningDeleteExecutionsSelector.Select(ctx)
187 }
188
189 > if nextPageToken == nil { workflow.go
190 break
191 }
go.temporal.io/server/service/worker/deletenamespace/deleteexecutions/config.go 4 introduced LOC · 1 range

Open complete file

52 }
53
54 > func (cfg *DeleteExecutionsConfig) String() string { config.go
55 > cfgBytes, _ := json.Marshal(cfg)
56 > return string(cfgBytes)
57 > }