MCPcopy Create free account
hub / github.com/cozystack/cozystack / ParseShardIndex

Function ParseShardIndex

internal/fluxshardoperator/config.go:103–113  ·  view source on GitHub ↗

ParseShardIndex parses a canonical shard key value ("shard ") back into its index. Non-canonical values (including the legacy "tenants" bucket) return ok=false.

(s string)

Source from the content-addressed store, hash-verified

101// its index. Non-canonical values (including the legacy "tenants" bucket)
102// return ok=false.
103func ParseShardIndex(s string) (int, bool) {
104 rest, found := strings.CutPrefix(s, shardPrefix)
105 if !found || rest == "" {
106 return 0, false
107 }
108 i, err := strconv.Atoi(rest)
109 if err != nil || i < 0 || ShardName(i) != s {
110 return 0, false
111 }
112 return i, true
113}
114
115// ParseShardDeploymentIndex parses a shard Deployment name back into its
116// shard index.

Callers 11

ComputePlacementFunction · 0.85
rebalanceFunction · 0.85
gatherMethod · 0.85
majorityShardFunction · 0.85
loadsOfFunction · 0.85
TestParseShardIndexFunction · 0.85
HandleMethod · 0.85
ParsePinnedTenantsFunction · 0.85

Calls 1

ShardNameFunction · 0.85

Tested by 4

loadsOfFunction · 0.68
TestParseShardIndexFunction · 0.68