history_archiver.go ×7

Frontier kind: Code frontier

unlabeled · c_c6f7e5db8a58

3 tests · 2135 LOC · 88 files · introduces 0 tests · 39 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges39 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
341 ranges2135 lines · 88 files · Browse complete extent
All tests (intent)
3 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.

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

go.temporal.io/server/common/archiver/s3store/history_archiver.go 19 introduced LOC · 7 ranges

Open complete file

175 }
176
177 > encoder := codec.NewJSONPBEncoder() history_archiver.go
178 > encodedHistoryBlob, err := encoder.Encode(historyBlob)
179 > if err != nil {
180 logger.Error(archiver.ArchiveNonRetryableErrorMsg, tag.ArchivalArchiveFailReason(errEncodeHistory), tag.Error(err))
181 return err
182 }
183 > key := constructHistoryKey(URI.Path(), request.NamespaceID, request.WorkflowID, request.RunID, request.CloseFailoverVersion, progress.BatchIdx) history_archiver.go
184 >
185 > exists, err := KeyExists(ctx, h.s3cli, URI, key)
186 > if err != nil {
187 if isRetryableError(err) {
188 logger.Error(archiver.ArchiveTransientErrorMsg, tag.ArchivalArchiveFailReason(errWriteKey), tag.Error(err))
192 return err
193 }
194 > blobSize := int64(binary.Size(encodedHistoryBlob)) history_archiver.go
195 > if exists {
196 metrics.HistoryArchiverBlobExistsCount.With(handler).Record(1)
197 > } else { history_archiver.go
198 > if err := Upload(ctx, h.s3cli, URI, key, encodedHistoryBlob); err != nil {
199 if isRetryableError(err) {
200 logger.Error(archiver.ArchiveTransientErrorMsg, tag.ArchivalArchiveFailReason(errWriteKey), tag.Error(err))
204 return err
205 }
206 > progress.uploadedSize += blobSize history_archiver.go
207 > handler.Histogram(metrics.HistoryArchiverBlobSize.Name(), metrics.HistoryArchiverBlobSize.Unit()).Record(blobSize)
208 }
209
210 > progress.historySize += blobSize history_archiver.go
211 > progress.BatchIdx = progress.BatchIdx + 1
212 > saveHistoryIteratorState(ctx, featureCatalog, historyIterator, &progress)
213 }
214
238 }
239
240 > func saveHistoryIteratorState(ctx context.Context, featureCatalog *archiver.ArchiveFeatureCatalog, historyIterator archiver.HistoryIterator, progress *uploadProgress) { history_archiver.go
241 > // Saving history state is a best effort operation. Ignore errors and continue
242 > if featureCatalog.ProgressManager != nil {
243 state, err := historyIterator.GetState()
244 if err != nil {
go.temporal.io/server/common/archiver/s3store/util.go 12 introduced LOC · 2 ranges

Open complete file

91 }
92
93 > func KeyExists(ctx context.Context, s3cli S3API, URI archiver.URI, key string) (bool, error) { util.go
94 > ctx, cancel := ensureContextTimeout(ctx)
95 > defer cancel()
96 > _, err := s3cli.HeadObject(ctx, &s3.HeadObjectInput{
97 > Bucket: aws.String(URI.Hostname()),
98 > Key: aws.String(key),
99 > })
100 > if err != nil {
101 > if IsNotFoundError(err) {
102 > return false, nil
103 > }
104 return false, err
105 }
243 }
244
245 > if !isLast { util.go
246 return false
247 }
go.temporal.io/server/common/archiver/s3store/mocks/s3api.go 8 introduced LOC · 2 ranges

Open complete file

83
84 // HeadObject mocks base method.
85 > func (m *MockS3API) HeadObject(ctx context.Context, params *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error) { s3api.go
86 > m.ctrl.T.Helper()
87 > varargs := []any{ctx, params}
88 > for _, a := range optFns {
89 varargs = append(varargs, a)
90 }
91 > ret := m.ctrl.Call(m, "HeadObject", varargs...) s3api.go
92 > ret0, _ := ret[0].(*s3.HeadObjectOutput)
93 > ret1, _ := ret[1].(error)
94 > return ret0, ret1
95 }
96