partition_counts.go ×8

Frontier kind: Code frontier

unlabeled · c_b024ef4460f9

21 tests · 1902 LOC · 78 files · introduces 0 tests · 33 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges33 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
266 ranges1902 lines · 78 files · Browse complete extent
All tests (intent)
21 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 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/client/matching/partition_counts.go 33 introduced LOC · 8 ranges

Open complete file

49 }
50
51 > func (pc PartitionCounts) appendToOutgoingContext(ctx context.Context) context.Context { partition_counts.go
52 > v, err := pc.encode(false) // don't include backlog info in header (client -> server)
53 > if err != nil {
54 return ctx
55 }
56 > return metadata.AppendToOutgoingContext(ctx, partitionCountsHeaderName, v) partition_counts.go
57 }
58
65 }
66
67 > func (pc PartitionCounts) Equal(other PartitionCounts) bool { partition_counts.go
68 > return pc.Read == other.Read &&
69 > pc.Write == other.Write &&
70 > pc.BacklogCap == other.BacklogCap &&
71 > bytes.Equal(pc.BacklogCount, other.BacklogCount)
72 > }
73
74 func parsePartitionCounts(hdr string) (PartitionCounts, error) {
92 }
93
94 > func parsePartitionCountsFromTrailer(trailer metadata.MD) (PartitionCounts, error) { partition_counts.go
95 > vals := trailer.Get(partitionCountsTrailerName)
96 > if len(vals) == 0 {
97 return PartitionCounts{}, nil
98 }
117 opts []grpc.CallOption,
118 ) (Res, error),
119 > ) (Res, error) { partition_counts.go
120 > // capture trailer
121 > var trailer metadata.MD
122 > opts = append(slices.Clone(opts), grpc.Trailer(&trailer))
123 >
124 > // get current idea of partition counts. if missing from the cache, this will send zeros
125 > // for counts, which the server will always accept as not-stale.
126 > pc := cache.lookup(pkey)
127 >
128 > for attempt := 0; ; attempt++ {
129 > res, err := op(pc.appendToOutgoingContext(ctx), pc, request, opts)
130 >
131 > // update cache on trailer on both success and error. if the trailer has no data,
132 > // this removes the key from the cache.
133 > newPc, parseErr := parsePartitionCountsFromTrailer(trailer)
134 > trailer = nil
135 > if parseErr != nil {
136 logger.Info("partition count trailer parse error", tag.Error(parseErr))
137 // continue with zero value for newPc
138 }
139 > if !newPc.Equal(pc) { partition_counts.go
140 cache.put(pkey, newPc)
141 pc = newPc
142 }
143
144 > if _, ok := errors.AsType[*serviceerrors.StalePartitionCounts](err); ok && attempt == 0 { partition_counts.go
145 // if we got a StalePartitionCounts on the first attempt, retry once
146 continue
147 }
148
149 > return res, err partition_counts.go
150 }
151 }