mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-02 17:50:39 +00:00
introduce ParsePseudoNodeID
unused for now A convenient place to document and deal with the ugliness.
This commit is contained in:
14
render/id.go
14
render/id.go
@@ -23,6 +23,20 @@ func MakePseudoNodeID(parts ...string) string {
|
||||
return strings.Join(append([]string{"pseudo"}, parts...), ":")
|
||||
}
|
||||
|
||||
// ParsePseudoNodeID returns the joined id parts of a pseudonode
|
||||
// ID. If the ID is not recognisable as a pseudonode ID, it is
|
||||
// returned as is, with the returned bool set to false. That is
|
||||
// convenient because not all pseudonode IDs actually follow the
|
||||
// format produced by MakePseudoNodeID.
|
||||
func ParsePseudoNodeID(nodeID string) (string, bool) {
|
||||
// Not using strings.SplitN() to avoid a heap allocation
|
||||
pos := strings.Index(nodeID, ":")
|
||||
if pos == -1 || nodeID[:pos] != "pseudo" {
|
||||
return nodeID, false
|
||||
}
|
||||
return nodeID[pos+1:], true
|
||||
}
|
||||
|
||||
// MakeGroupNodeTopology joins the parts of a group topology into the topology of a group node
|
||||
func MakeGroupNodeTopology(originalTopology, key string) string {
|
||||
return strings.Join([]string{"group", originalTopology, key}, ":")
|
||||
|
||||
Reference in New Issue
Block a user