service_resolver.go ×5

Frontier kind: Code frontier

unlabeled · c_40286182fd86

15 tests · 1819 LOC · 78 files · introduces 0 tests · 32 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges32 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
247 ranges1819 lines · 78 files · Browse complete extent
All tests (intent)
15 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.

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

go.temporal.io/server/common/membership/ringpop/service_resolver.go 18 introduced LOC · 5 ranges

Open complete file

440 }
441
442 > func (r *serviceResolver) ring() (*hashring.HashRing, map[string]*hostInfo) { service_resolver.go
443 > ring := r.ringAndHosts.Load().(ringAndHosts)
444 > return ring.ring, ring.hosts
445 > }
446
447 > func (r *serviceResolver) compareMembers(hosts []*hostInfo) (map[string]*hostInfo, *membership.ChangedEvent) { service_resolver.go
448 > event := &membership.ChangedEvent{}
449 > changed := false
450 > _, prevHosts := r.ring() // note that this is always called with refreshLock so we can't miss an update here
451 > newMembersMap := make(map[string]*hostInfo, len(hosts))
452 > for _, host := range hosts {
453 > newMembersMap[host.GetAddress()] = host
454 > if prev, ok := prevHosts[host.GetAddress()]; !ok {
455 event.HostsAdded = append(event.HostsAdded, host)
456 changed = true
457 > } else if prev.labelsChecksum != host.labelsChecksum { service_resolver.go
458 event.HostsChanged = append(event.HostsChanged, host)
459 changed = true
460 }
461 }
462 > for addr, prev := range prevHosts { service_resolver.go
463 > if _, ok := newMembersMap[addr]; !ok {
464 event.HostsRemoved = append(event.HostsRemoved, prev)
465 changed = true
466 }
467 }
468 > if changed { service_resolver.go
469 > return newMembersMap, event
470 > }
471 return newMembersMap, nil
472 }
go.temporal.io/server/common/membership/ringpop/hostinfo.go 14 introduced LOC · 4 ranges

Open complete file

23
24 // newHostInfo creates a new *hostInfo instance
25 > func newHostInfo(addr string, labels map[string]string) *hostInfo { hostinfo.go
26 > return &hostInfo{
27 > addr: addr,
28 > labels: labels,
29 > labelsChecksum: checksumLabels(labels),
30 > }
31 > }
32
33 // GetAddress returns the ip:port address
34 > func (hi *hostInfo) GetAddress() string { hostinfo.go
35 > return hi.addr
36 > }
37
38 // Identity implements ringpop's Membership interface
64
65 // checksumLabels returns a checksum of a labels map
66 > func checksumLabels(labels map[string]string) uint64 { hostinfo.go
67 > var c uint64
68 > for k, v := range labels {
69 kfp := farm.Fingerprint64([]byte(k))
70 vfp := farm.Fingerprint64([]byte(v))
73 c ^= kfp + bits.RotateLeft64(vfp, 3)
74 }
75 > return c hostinfo.go
76 }