MCPcopy
hub / github.com/CodisLabs/codis / handleOverview

Method handleOverview

cmd/admin/dashboard.go:111–165  ·  view source on GitHub ↗
(d map[string]interface{})

Source from the content-addressed store, hash-verified

109}
110
111func (t *cmdDashboard) handleOverview(d map[string]interface{}) {
112 c := t.newTopomClient()
113
114 log.Debugf("call rpc overview to dashboard %s", t.addr)
115 o, err := c.Overview()
116 if err != nil {
117 log.PanicErrorf(err, "call rpc overview to dashboard %s failed", t.addr)
118 }
119 log.Debugf("call rpc overview OK")
120
121 var cmd string
122 for _, s := range []string{"config", "model", "slots", "stats", "group", "proxy", "--list-group", "--list-proxy"} {
123 if d[s].(bool) {
124 cmd = s
125 }
126 }
127
128 var obj interface{}
129 switch cmd {
130 default:
131 obj = o
132 case "config":
133 obj = o.Config
134 case "model":
135 obj = o.Model
136 case "stats":
137 obj = o.Stats
138 case "slots":
139 if o.Stats != nil {
140 obj = o.Stats.Slots
141 }
142 case "group":
143 if o.Stats != nil {
144 obj = o.Stats.Group
145 }
146 case "--list-group":
147 if o.Stats != nil {
148 obj = o.Stats.Group.Models
149 }
150 case "proxy":
151 if o.Stats != nil {
152 obj = o.Stats.Proxy
153 }
154 case "--list-proxy":
155 if o.Stats != nil {
156 obj = o.Stats.Proxy.Models
157 }
158 }
159
160 b, err := json.MarshalIndent(obj, "", " ")
161 if err != nil {
162 log.PanicErrorf(err, "json marshal failed")
163 }
164 fmt.Println(string(b))
165}
166
167func (t *cmdDashboard) handleLogLevel(d map[string]interface{}) {
168 c := t.newTopomClient()

Callers 1

MainMethod · 0.95

Calls 5

newTopomClientMethod · 0.95
DebugfMethod · 0.80
PanicErrorfMethod · 0.80
PrintlnMethod · 0.80
OverviewMethod · 0.45

Tested by

no test coverage detected