go.temporal.io/server/common/archiver/util.go

122 LOC · 64 covered · 58 uncovered · 29 ranges · 185 concepts · 17 introducers · 85 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 archiver
2
3 import (
4 "errors"
5
6 archiverspb "go.temporal.io/server/api/archiver/v1"
7 "go.temporal.io/server/common/log"
8 "go.temporal.io/server/common/log/tag"
9 )
10
11 var (
12 errEmptyNamespaceID = errors.New("field NamespaceId is empty")
13 errEmptyNamespace = errors.New("field Namespace is empty")
14 errEmptyWorkflowID = errors.New("field WorkflowId is empty")
15 errEmptyRunID = errors.New("field RunId is empty")
16 errInvalidPageSize = errors.New("field PageSize should be greater than 0")
17 errEmptyWorkflowTypeName = errors.New("field WorkflowTypeName is empty")
18 errEmptyStartTime = errors.New("field StartTime is empty")
19 errEmptyCloseTime = errors.New("field CloseTime is empty")
20 )
21
22 // TagLoggerWithArchiveHistoryRequestAndURI tags logger with fields in the archive history request and the URI
23 > func TagLoggerWithArchiveHistoryRequestAndURI(logger log.Logger, request *ArchiveHistoryRequest, URI string) log.Logger { util.go ×1
24 > return log.With(
25 > logger,
26 > tag.ShardID(request.ShardID),
27 > tag.ArchivalRequestNamespaceID(request.NamespaceID),
28 > tag.ArchivalRequestNamespace(request.Namespace),
29 > tag.ArchivalRequestWorkflowID(request.WorkflowID),
30 > tag.ArchivalRequestRunID(request.RunID),
31 > tag.ArchivalRequestBranchToken(request.BranchToken),
32 > tag.ArchivalRequestNextEventID(request.NextEventID),
33 > tag.ArchivalRequestCloseFailoverVersion(request.CloseFailoverVersion),
34 > tag.ArchivalURI(URI),
35 > )
36 > }
37
38 // TagLoggerWithArchiveVisibilityRequestAndURI tags logger with fields in the archive visibility request and the URI
39 > func TagLoggerWithArchiveVisibilityRequestAndURI(logger log.Logger, request *archiverspb.VisibilityRecord, URI string) log.Logger { message.pb.go ×4
40 > return log.With(
41 > logger,
42 > tag.ArchivalRequestNamespaceID(request.GetNamespaceId()),
43 > tag.ArchivalRequestNamespace(request.GetNamespace()),
44 > tag.ArchivalRequestWorkflowID(request.GetWorkflowId()),
45 > tag.ArchivalRequestRunID(request.GetRunId()),
46 > tag.ArchvialRequestWorkflowType(request.GetWorkflowTypeName()),
47 > tag.ArchivalRequestCloseTimestamp(request.GetCloseTime()),
48 > tag.ArchivalRequestStatus(request.GetStatus().String()),
49 > tag.ArchivalURI(URI),
50 > )
51 > }
52
53 // ValidateHistoryArchiveRequest validates the archive history request
54 > func ValidateHistoryArchiveRequest(request *ArchiveHistoryRequest) error { util.go ×2
55 > if request.NamespaceID == "" {
56 return errEmptyNamespaceID
57 }
58 > if request.WorkflowID == "" { util.go ×2
59 > return errEmptyWorkflowID util.go ×1
60 > }
61 > if request.RunID == "" { history_iterator_mock.go ×5
62 return errEmptyRunID
63 }
64 > if request.Namespace == "" { history_iterator_mock.go ×5
65 return errEmptyNamespace
66 }
68 }
69
70 // ValidateGetRequest validates the get archived history request
71 > func ValidateGetRequest(request *GetHistoryRequest) error { util.go ×4
72 > if request.NamespaceID == "" {
73 return errEmptyNamespaceID
74 }
75 > if request.WorkflowID == "" { util.go ×4
76 return errEmptyWorkflowID
77 }
78 > if request.RunID == "" { util.go ×4
79 return errEmptyRunID
80 }
81 > if request.PageSize == 0 { util.go ×4
82 > return errInvalidPageSize util.go ×1
83 > }
84 > return nil util.go ×1
85 }
86
87 // ValidateVisibilityArchivalRequest validates the archive visibility request
88 > func ValidateVisibilityArchivalRequest(request *archiverspb.VisibilityRecord) error { util.go ×1
89 > if request.GetNamespaceId() == "" {
90 > return errEmptyNamespaceID util.go ×1
91 > }
92 > if request.GetNamespace() == "" { util.go ×7
93 > return errEmptyNamespace visibility_archiver.go ×1
94 > }
95 > if request.GetWorkflowId() == "" { util.go ×7
96 return errEmptyWorkflowID
97 }
98 > if request.GetRunId() == "" { util.go ×7
99 return errEmptyRunID
100 }
101 > if request.GetWorkflowTypeName() == "" { util.go ×7
102 return errEmptyWorkflowTypeName
103 }
104 > if request.GetStartTime() == nil || request.GetStartTime().AsTime().IsZero() { util.go ×7
105 return errEmptyStartTime
106 }
107 > if request.GetCloseTime() == nil || request.GetCloseTime().AsTime().IsZero() { util.go ×7
108 return errEmptyCloseTime
109 }
110 > return nil util.go ×7
111 }
112
113 // ValidateQueryRequest validates the query visibility request
114 > func ValidateQueryRequest(request *QueryVisibilityRequest) error { util.go ×1
115 > if request.NamespaceID == "" {
116 > return errEmptyNamespaceID util.go ×1
117 > }
118 > if request.PageSize == 0 { util.go ×1
119 > return errInvalidPageSize util.go ×1
120 > }
121 > return nil util.go ×1
122 }