mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-11 03:38:18 +00:00
refactor: better naming for MapEndpoints parameters
This commit is contained in:
@@ -70,8 +70,8 @@ func (c connectionJoin) Render(ctx context.Context, rpt report.Report) Nodes {
|
||||
}
|
||||
}
|
||||
return MapEndpoints(
|
||||
func(m report.Node) string {
|
||||
scope, addr, port, ok := report.ParseEndpointNodeID(m.ID)
|
||||
func(endpoint report.Node) string {
|
||||
scope, addr, port, ok := report.ParseEndpointNodeID(endpoint.ID)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -15,18 +15,18 @@ const Pseudo = "pseudo"
|
||||
// EndpointRenderer is a Renderer which produces a renderable endpoint graph.
|
||||
var EndpointRenderer = SelectEndpoint
|
||||
|
||||
type endpointMapFunc func(report.Node) string
|
||||
type endpointToIDFunc func(report.Node) string
|
||||
|
||||
type mapEndpoints struct {
|
||||
f endpointMapFunc
|
||||
topology string
|
||||
endpointToID endpointToIDFunc
|
||||
topology string
|
||||
}
|
||||
|
||||
// MapEndpoints creates a renderer for the endpoint topology. Each
|
||||
// endpoint is either turned into a pseudo node, or mapped to a node
|
||||
// in the specified topology by the supplied function.
|
||||
func MapEndpoints(f endpointMapFunc, topology string) Renderer {
|
||||
return mapEndpoints{f: f, topology: topology}
|
||||
func MapEndpoints(endpointToID endpointToIDFunc, topology string) Renderer {
|
||||
return mapEndpoints{endpointToID: endpointToID, topology: topology}
|
||||
}
|
||||
|
||||
func (e mapEndpoints) Render(ctx context.Context, rpt report.Report) Nodes {
|
||||
@@ -43,7 +43,7 @@ func (e mapEndpoints) Render(ctx context.Context, rpt report.Report) Nodes {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if id := e.f(n); id != "" {
|
||||
if id := e.endpointToID(n); id != "" {
|
||||
ret.addChild(n, id, e.topology)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ func nodes2Hosts(nodes Nodes) Nodes {
|
||||
return ret.result(nodes)
|
||||
}
|
||||
|
||||
func endpoint2Host(n report.Node) string {
|
||||
if hostNodeID, ok := n.Latest.Lookup(report.HostNodeID); ok {
|
||||
func endpoint2Host(endpoint report.Node) string {
|
||||
if hostNodeID, ok := endpoint.Latest.Lookup(report.HostNodeID); ok {
|
||||
return hostNodeID
|
||||
}
|
||||
return ""
|
||||
|
||||
@@ -49,15 +49,15 @@ func (e endpoints2Processes) Render(ctx context.Context, rpt report.Report) Node
|
||||
}
|
||||
endpoints := SelectEndpoint.Render(ctx, rpt).Nodes
|
||||
return MapEndpoints(
|
||||
func(n report.Node) string {
|
||||
pid, ok := n.Latest.Lookup(report.PID)
|
||||
func(endpoint report.Node) string {
|
||||
pid, ok := endpoint.Latest.Lookup(report.PID)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
if hasMoreThanOneConnection(n, endpoints) {
|
||||
if hasMoreThanOneConnection(endpoint, endpoints) {
|
||||
return ""
|
||||
}
|
||||
hostID := report.ExtractHostID(n)
|
||||
hostID := report.ExtractHostID(endpoint)
|
||||
if hostID == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user