Skip to content

Commit 77f88cf

Browse files
committed
style(opensearchtransport): extract clusterHealthName constant
Collapse the duplicated "cluster_health" literal (OperationID.String label and discovery-flag map key) into one unexported constant, reused across the package and internal tests. Clears the goconst threshold that the new tests tripped and ties the token's uses together for tooling. Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent 523eabc commit 77f88cf

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

opensearchtransport/feature_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (f discoveryFeatures) nodeStatsEnabled() bool {
175175
var discoveryFlagNames = map[string]discoveryFeatures{
176176
"cat_shards": discoverySkipCatShards,
177177
"routing_num_shards": discoverySkipRoutingNumShards,
178-
"cluster_health": discoverySkipClusterHealth,
178+
clusterHealthName: discoverySkipClusterHealth,
179179
"node_stats": discoverySkipNodeStats,
180180
}
181181

opensearchtransport/observer_response_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func TestRequestEventIdentityFields(t *testing.T) {
182182
name: "system endpoint has empty index",
183183
method: http.MethodGet,
184184
path: "/_cluster/health",
185-
wantRouteName: "cluster_health",
185+
wantRouteName: clusterHealthName,
186186
wantIndex: "",
187187
wantPath: "/_cluster/health",
188188
},

opensearchtransport/operation.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,14 @@ const OpRenderSearchTemplate = CatSearch | minRenderSearchTemplate
612612
// OpPing identifies a cluster ping operation.
613613
const OpPing = CatPing | minPing
614614

615+
// Operation name tokens shared between the [OperationID.String] labels and other
616+
// package sites that must spell the same wire token (e.g. discovery-flag names).
617+
// Extracting them keeps the spellings in lockstep and lets tooling trace every
618+
// use of a token back to one declaration.
619+
const (
620+
clusterHealthName = "cluster_health"
621+
)
622+
615623
// ---------------------------------------------------------------------------
616624
// String
617625
// ---------------------------------------------------------------------------
@@ -807,7 +815,7 @@ func (op OperationID) String() string {
807815
case OpClusterInfo:
808816
return "cluster_info"
809817
case OpClusterHealth:
810-
return "cluster_health"
818+
return clusterHealthName
811819
case OpClusterStats:
812820
return "cluster_stats"
813821
case OpClusterState:

0 commit comments

Comments
 (0)