cluster_metadata_loader.go ×8

Frontier kind: Code frontier

unlabeled · c_d5db154b9fef

13 tests · 3032 LOC · 152 files · introduces 0 tests · 27 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges27 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
456 ranges3032 lines · 152 files · Browse complete extent
All tests (intent)
13 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: 27 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/temporal/cluster_metadata_loader.go 27 introduced LOC · 8 ranges

Open complete file

20
21 // NewClusterMetadataLoader creates a new [ClusterMetadataLoader] that loads cluster metadata from the database.
22 > func NewClusterMetadataLoader(manager persistence.ClusterMetadataManager, logger log.Logger) *ClusterMetadataLoader { cluster_metadata_loader.go
23 > return &ClusterMetadataLoader{
24 > manager: manager,
25 > logger: logger,
26 > }
27 > }
28
29 // LoadAndMergeWithStaticConfig loads cluster metadata from the database and merges it with the static config.
30 > func (c *ClusterMetadataLoader) LoadAndMergeWithStaticConfig(ctx context.Context, svc *config.Config) error { cluster_metadata_loader.go
31 > iter := cluster.GetAllClustersIter(ctx, c.manager)
32 >
33 > for iter.HasNext() {
34 > item, err := iter.Next()
35 > if err != nil {
36 return err
37 }
38 > newMetadata := cluster.ClusterInformationFromDB(item) cluster_metadata_loader.go
39 > c.mergeMetadataFromDBWithStaticConfig(svc, item.ClusterName, newMetadata)
40 }
41 > return nil cluster_metadata_loader.go
42 }
43
44 > func (c *ClusterMetadataLoader) mergeMetadataFromDBWithStaticConfig(svc *config.Config, clusterName string, newMetadata *cluster.ClusterInformation) { cluster_metadata_loader.go
45 > c.backfillShardCount(svc, newMetadata)
46 > if currentMetadata, ok := svc.ClusterMetadata.ClusterInformation[clusterName]; ok {
47 > c.reconcileMetadata(svc, clusterName, currentMetadata, newMetadata)
48 > }
49 > svc.ClusterMetadata.ClusterInformation[clusterName] = *newMetadata
50 }
51
56 currentMetadata cluster.ClusterInformation,
57 newMetadata *cluster.ClusterInformation,
59 > if clusterName != svc.ClusterMetadata.CurrentClusterName {
60 c.logger.Warn(
61 "ClusterInformation in static config is deprecated. Please use TCTL tool to configure remote cluster connections",
65 return
66 }
67 > newMetadata.RPCAddress = currentMetadata.RPCAddress cluster_metadata_loader.go
68 > c.logger.Info(fmt.Sprintf("Use rpc address %v for cluster %v.", newMetadata.RPCAddress, clusterName))
69 }
70
71 // backfillShardCount is to add backward compatibility to the svc based cluster connection. It sets the shard count for
72 // newMetadata to the number of shards in the current cluster, if the shard count is not set in the database.
73 > func (c *ClusterMetadataLoader) backfillShardCount(svc *config.Config, newMetadata *cluster.ClusterInformation) { cluster_metadata_loader.go
74 > if newMetadata.ShardCount == 0 {
75 newMetadata.ShardCount = svc.Persistence.NumHistoryShards
76 }