event_importer.go ×14

Frontier kind: Joint frontier

unlabeled · c_73c6d8118932

1 test · 2857 LOC · 135 files · introduces 1 test · 85 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
20 ranges85 lines · 4 files
Tests
1 test

Contains — complete concept membership

All code (extent)
516 ranges2857 lines · 135 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

4 files ranked by introduced lines: 85 introduced LOC across 20 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/replication/eventhandler/event_importer.go 62 introduced LOC · 14 ranges

Open complete file

65 endEventId int64,
66 endEventVersion int64,
67 > ) error { event_importer.go
68 > historyIterator := e.historyFetcher.GetSingleWorkflowHistoryPaginatedIteratorInclusive(
69 > ctx,
70 > remoteCluster,
71 > namespace.ID(workflowKey.NamespaceID),
72 > workflowKey.WorkflowID,
73 > workflowKey.RunID,
74 > common.EmptyEventID,
75 > common.EmptyVersion,
76 > endEventId,
77 > endEventVersion,
78 > )
79 > engine, err := e.engineProvider(ctx, namespace.ID(workflowKey.NamespaceID), workflowKey.WorkflowID)
80 > if err != nil {
81 return err
82 }
83
84 > var blobs []*commonpb.DataBlob event_importer.go
85 > blobSize := 0
86 > var token []byte
87 > var versionHistory *historyspb.VersionHistory
88 > eventsVersion := common.EmptyVersion
89 > importFn := func() error {
90 > res, err := invokeImportWorkflowExecutionCall(ctx, engine, workflowKey, blobs, versionHistory, token, e.logger)
91 > if err != nil {
92 return err
93 }
94 > token = res.Token event_importer.go
95 > blobs = []*commonpb.DataBlob{}
96 > blobSize = 0
97 > eventsVersion = common.EmptyVersion
98 > return nil
99 }
100 > for historyIterator.HasNext() { event_importer.go
101 > batch, err := historyIterator.Next()
102 > if err != nil {
103 e.logger.Error("failed to get history events",
104 tag.WorkflowNamespaceID(workflowKey.NamespaceID),
109 }
110
111 > if versionHistory != nil && !versionhistory.IsVersionHistoryItemsInSameBranch(versionHistory.Items, batch.VersionHistory.Items) { event_importer.go
112 return serviceerror.NewInternal("History Branch changed during importing")
113 }
114 > events, err := e.serializer.DeserializeEvents(batch.RawEventBatch) event_importer.go
115 > if err != nil {
116 return err
117 }
118 > if len(events) == 0 { event_importer.go
119 return serviceerror.NewInternal("Empty events received when importing")
120 }
121 > if eventsVersion != common.EmptyVersion && eventsVersion != events[0].GetVersion() { event_importer.go
122 > if err := importFn(); err != nil {
123 return err
124 }
125 }
126 > versionHistory = batch.VersionHistory event_importer.go
127 > eventsVersion = events[0].GetVersion()
128 > blobSize += len(batch.RawEventBatch.Data)
129 > blobs = append(blobs, batch.RawEventBatch)
130 >
131 > if blobSize >= historyImportPageSize || len(blobs) >= historyImportBlobSize {
132 if err := importFn(); err != nil {
133 return err
135 }
136 }
137 > if len(blobs) != 0 { event_importer.go
138 > err = importFn()
139 > if err != nil {
140 return err
141 }
143
144 // call with empty event blob to commit the import
145 > response, err := invokeImportWorkflowExecutionCall(ctx, engine, workflowKey, blobs, versionHistory, token, e.logger) event_importer.go
146 > if err != nil || len(response.Token) != 0 {
147 e.logger.Error("failed to commit import action",
148 tag.WorkflowNamespaceID(workflowKey.NamespaceID),
152 return serviceerror.NewInternal("Failed to commit import transaction")
153 }
154 > return nil event_importer.go
155 }
156
163 token []byte,
164 logger log.Logger,
165 > ) (*historyservice.ImportWorkflowExecutionResponse, error) { event_importer.go
166 > request := &historyservice.ImportWorkflowExecutionRequest{
167 > NamespaceId: workflowKey.NamespaceID,
168 > Execution: &commonpb.WorkflowExecution{
169 > WorkflowId: workflowKey.WorkflowID,
170 > RunId: workflowKey.RunID,
171 > },
172 > HistoryBatches: historyBatches,
173 > VersionHistory: versionHistory,
174 > Token: token,
175 > }
176 > response, err := historyEngine.ImportWorkflowExecution(ctx, request)
177 > if err != nil {
178 return nil, serviceerror.NewInternal("Failed to import events")
179 }
180 > return response, nil event_importer.go
181 }
go.temporal.io/server/service/history/interfaces/engine_mock.go 11 introduced LOC · 2 ranges

Open complete file

341
342 // ImportWorkflowExecution mocks base method.
343 > func (m *MockEngine) ImportWorkflowExecution(ctx context.Context, request *historyservice.ImportWorkflowExecutionRequest) (*historyservice.ImportWorkflowExecutionResponse, error) { engine_mock.go
344 > m.ctrl.T.Helper()
345 > ret := m.ctrl.Call(m, "ImportWorkflowExecution", ctx, request)
346 > ret0, _ := ret[0].(*historyservice.ImportWorkflowExecutionResponse)
347 > ret1, _ := ret[1].(error)
348 > return ret0, ret1
349 > }
350
351 // ImportWorkflowExecution indicates an expected call of ImportWorkflowExecution.
352 > func (mr *MockEngineMockRecorder) ImportWorkflowExecution(ctx, request any) *gomock.Call { engine_mock.go
353 > mr.mock.ctrl.T.Helper()
354 > return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImportWorkflowExecution", reflect.TypeOf((*MockEngine)(nil).ImportWorkflowExecution), ctx, request)
355 > }
356
357 // IsActivityTaskValid mocks base method.
go.temporal.io/server/api/historyservice/v1/request_response.go-helpers.pb.go 7 introduced LOC · 3 ranges

Open complete file

3762 // For more information see the documentation for
3763 // https://pkg.go.dev/google.golang.org/protobuf/proto#Equal
3764 > func (this *ImportWorkflowExecutionRequest) Equal(that interface{}) bool { request_response.go-helpers.pb.go
3765 > if that == nil {
3766 return this == nil
3767 }
3768
3769 > var that1 *ImportWorkflowExecutionRequest request_response.go-helpers.pb.go
3770 > switch t := that.(type) {
3771 > case *ImportWorkflowExecutionRequest:
3772 > that1 = t
3773 case ImportWorkflowExecutionRequest:
3774 that1 = &t
go.temporal.io/server/api/historyservice/v1/request_response.pb.go 5 introduced LOC · 1 range

Open complete file

7037 mi := &file_temporal_server_api_historyservice_v1_request_response_proto_msgTypes[101]
7038 if x != nil {
7039 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) request_response.pb.go
7040 > if ms.LoadMessageInfo() == nil {
7041 > ms.StoreMessageInfo(mi)
7042 > }
7043 > return ms
7044 }
7045 return mi.MessageOf(x)