/
overview.go
44 lines (38 loc) Β· 977 Bytes
/
overview.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package overview
import (
"context"
"github.com/coroot/coroot/clickhouse"
"github.com/coroot/coroot/model"
)
type Overview struct {
Health []*ApplicationStatus `json:"health"`
Map []*Application `json:"map"`
Nodes *model.Table `json:"nodes"`
Deployments []*Deployment `json:"deployments"`
Traces *Traces `json:"traces"`
Costs *Costs `json:"costs"`
}
func Render(ctx context.Context, ch *clickhouse.Client, w *model.World, view, query string) *Overview {
v := &Overview{}
for _, n := range w.Nodes {
if n.Price != nil {
v.Costs = &Costs{}
break
}
}
switch view {
case "health":
v.Health = renderHealth(w)
case "map":
v.Map = renderServiceMap(w)
case "nodes":
v.Nodes = renderNodes(w)
case "deployments":
v.Deployments = renderDeployments(w)
case "traces":
v.Traces = renderTraces(ctx, ch, w, query)
case "costs":
v.Costs = renderCosts(w)
}
return v
}