task_user_data.go ×14

Frontier kind: Code frontier

unlabeled · c_708a99abb8f8

12 tests · 3216 LOC · 160 files · introduces 0 tests · 33 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges33 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
522 ranges3216 lines · 160 files · Browse complete extent
All tests (intent)
12 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.

1 file ranked by introduced lines: 33 introduced LOC across 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/sql/task_user_data.go 33 introduced LOC · 14 ranges

Open complete file

31 return nil, err
32 }
33 > return &persistence.InternalGetTaskQueueUserDataResponse{ task_user_data.go
34 > Version: response.Version,
35 > UserData: persistence.NewDataBlob(response.Data, response.DataEncoding),
36 > }, nil
37 }
38
39 // nolint:revive,cognitive-complexity // moving old code
40 > func (uds *userDataStore) UpdateTaskQueueUserData(ctx context.Context, request *persistence.InternalUpdateTaskQueueUserDataRequest) error { task_user_data.go
41 > namespaceID, err := primitives.ParseUUID(request.NamespaceID)
42 > if err != nil {
43 return serviceerror.NewInternalf("failed to parse namespace ID as UUID: %v", err)
44 }
45 > err = uds.txExecute(ctx, "UpdateTaskQueueUserData", func(tx sqlplugin.Tx) error { task_user_data.go
46 > for taskQueue, update := range request.Updates {
47 > err := tx.UpdateTaskQueueUserData(ctx, &sqlplugin.UpdateTaskQueueDataRequest{
48 > NamespaceID: namespaceID,
49 > TaskQueueName: taskQueue,
50 > Data: update.UserData.Data,
51 > DataEncoding: update.UserData.EncodingType.String(),
52 > Version: update.Version,
53 > })
54 > // note these are in a transaction: if one fails the others will be rolled back
55 > if uds.DB.IsDupEntryError(err) {
56 err = &persistence.ConditionFailedError{Msg: err.Error()}
57 }
58 > if persistence.IsConflictErr(err) && update.Conflicting != nil { task_user_data.go
59 *update.Conflicting = true
60 }
61 > if err != nil { task_user_data.go
62 return err
63 }
64 > if len(update.BuildIdsAdded) > 0 { task_user_data.go
65 err = tx.AddToBuildIdToTaskQueueMapping(ctx, sqlplugin.AddToBuildIdToTaskQueueMapping{
66 NamespaceID: namespaceID,
72 }
73 }
74 > if len(update.BuildIdsRemoved) > 0 { task_user_data.go
75 err = tx.RemoveFromBuildIdToTaskQueueMapping(ctx, sqlplugin.RemoveFromBuildIdToTaskQueueMapping{
76 NamespaceID: namespaceID,
83 }
84 }
85 > return nil task_user_data.go
86 })
87 // only set Applied if the whole transaction succeeded
88 > for _, update := range request.Updates { task_user_data.go
89 > if update.Applied != nil {
90 *update.Applied = err == nil
91 }
92 }
93 > return err task_user_data.go
94 }
95
155 }
156
157 > func (uds *userDataStore) txExecute(ctx context.Context, operation string, f func(tx sqlplugin.Tx) error) error { task_user_data.go
158 > tx, err := uds.DB.BeginTx(ctx)
159 > if err != nil {
160 return serviceerror.NewUnavailablef("%s failed. Failed to start transaction. Error: %v", operation, err)
161 }
162 > err = f(tx) task_user_data.go
163 > if err != nil {
164 rollBackErr := tx.Rollback()
165 if rollBackErr != nil {
180 }
181 }
182 > if err := tx.Commit(); err != nil { task_user_data.go
183 return serviceerror.NewUnavailablef("%s operation failed. Failed to commit transaction. Error: %v", operation, err)
184 }
185 > return nil task_user_data.go
186 }