progress_cache.go ×17

Frontier kind: Joint frontier

unlabeled · c_851bd0990edd

1 test · 4344 LOC · 189 files · introduces 1 test · 93 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges93 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
666 ranges4344 lines · 189 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.

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

go.temporal.io/server/service/history/replication/progress_cache.go 90 introduced LOC · 17 ranges

Open complete file

66 runID string,
67 targetClusterID int32,
68 > ) *ReplicationProgress { progress_cache.go
69 > cacheKey := makeCacheKey(runID, targetClusterID)
70 > c.cacheLock.RLock()
71 > defer c.cacheLock.RUnlock()
72 >
73 > progress, ok := c.cache.Get(cacheKey).(*ReplicationProgress)
74 > if !ok {
75 > return nil
76 > }
77 > return progress
78 }
79
81 item *ReplicationProgress,
82 versionedTransitions []*persistencespb.VersionedTransition,
83 > ) bool { progress_cache.go
84 > if len(versionedTransitions) == 0 {
85 return false
86 }
87
88 > if item.versionedTransitions == nil { progress_cache.go
89 > item.versionedTransitions = [][]*persistencespb.VersionedTransition{
90 > transitionhistory.CopyVersionedTransitions(versionedTransitions),
91 > }
92 > item.lastVersionTransitionIndex = 0
93 > return true
94 > }
95
96 > for idx, transitions := range item.versionedTransitions { progress_cache.go
97 > if transitionhistory.StalenessCheck(versionedTransitions, transitions[len(transitions)-1]) == nil {
98 > item.versionedTransitions[idx] = transitionhistory.CopyVersionedTransitions(versionedTransitions)
99 > item.lastVersionTransitionIndex = idx
100 > return true
101 > }
102 > if transitionhistory.StalenessCheck(transitions, versionedTransitions[len(versionedTransitions)-1]) == nil {
103 > // incoming versioned transitions are already included in the current versioned transitions
104 > return false
105 > }
106 }
107 > item.lastVersionTransitionIndex = len(item.versionedTransitions) progress_cache.go
108 > item.versionedTransitions = append(item.versionedTransitions, transitionhistory.CopyVersionedTransitions(versionedTransitions))
109 > return true
110 }
111
113 item *ReplicationProgress,
114 eventVersionHistoryItems []*historyspb.VersionHistoryItem,
115 > ) (bool, error) { progress_cache.go
116 > if len(eventVersionHistoryItems) == 0 {
117 return false, nil
118 }
119
120 > if item.eventVersionHistoryItems == nil { progress_cache.go
121 > item.eventVersionHistoryItems = [][]*historyspb.VersionHistoryItem{
122 > versionhistory.CopyVersionHistoryItems(eventVersionHistoryItems),
123 > }
124 > item.lastEventVersionHistoryIndex = 0
125 > return true, nil
126 > }
127
128 > for idx, historyItems := range item.eventVersionHistoryItems { progress_cache.go
129 > lcaItem, err := versionhistory.FindLCAVersionHistoryItemFromItemSlice(historyItems, eventVersionHistoryItems)
130 > if err != nil {
131 return false, err
132 }
133 > if versionhistory.IsEqualVersionHistoryItem(eventVersionHistoryItems[len(eventVersionHistoryItems)-1], lcaItem) { progress_cache.go
134 > // incoming version history is already included in the current version histories
135 > return false, nil
136 > }
137 > if versionhistory.IsEqualVersionHistoryItem(historyItems[len(historyItems)-1], lcaItem) {
138 > // incoming version history can be appended to the current version histories
139 > item.eventVersionHistoryItems[idx] = versionhistory.CopyVersionHistoryItems(eventVersionHistoryItems)
140 > item.lastEventVersionHistoryIndex = idx
141 > return true, nil
142 > }
143 }
144
145 > item.lastEventVersionHistoryIndex = len(item.eventVersionHistoryItems) progress_cache.go
146 > item.eventVersionHistoryItems = append(item.eventVersionHistoryItems, versionhistory.CopyVersionHistoryItems(eventVersionHistoryItems))
147 > return true, nil
148 }
149
153 versionedTransitions []*persistencespb.VersionedTransition,
154 eventVersionHistoryItems []*historyspb.VersionHistoryItem,
155 > ) error { progress_cache.go
156 > cacheKey := makeCacheKey(runID, targetClusterID)
157 > c.cacheLock.Lock()
158 > defer c.cacheLock.Unlock()
159 >
160 > item, ok := c.cache.Get(cacheKey).(*ReplicationProgress)
161 > if !ok {
162 > item = &ReplicationProgress{}
163 > }
164
165 > stateDirty := c.updateStates(item, versionedTransitions) progress_cache.go
166 > eventDirty, err := c.updateEvents(item, eventVersionHistoryItems)
167 > if err != nil {
168 return err
169 }
170
171 > if stateDirty || eventDirty { progress_cache.go
172 > c.cache.Put(cacheKey, item)
173 > }
174 > return nil
175 }
176
198 }
199
200 > func (c *ReplicationProgress) CacheSize() int { progress_cache.go
201 > size := int(unsafe.Sizeof(c.lastVersionTransitionIndex))
202 > for _, transitions := range c.versionedTransitions {
203 > for _, versionedTransition := range transitions {
204 > size += versionedTransition.Size()
205 > }
206 }
207 > for _, items := range c.eventVersionHistoryItems { progress_cache.go
208 > for _, item := range items {
209 > size += item.Size()
210 > }
211 }
212 > return size progress_cache.go
213 }
214
216 runID string,
217 targetClusterID int32,
218 > ) Key { progress_cache.go
219 > return Key{
220 > RunID: runID,
221 > TargetClusterID: targetClusterID,
222 > }
223 > }
go.temporal.io/server/api/persistence/v1/hsm.go-helpers.pb.go 3 introduced LOC · 1 range

Open complete file

239
240 // Size returns the size of the object, in bytes, once serialized
241 > func (val *VersionedTransition) Size() int { hsm.go-helpers.pb.go
242 > return proto.Size(val)
243 > }
244
245 // Equal returns whether two VersionedTransition values are equivalent by recursively