MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / statisticHandler

Method statisticHandler

pkg/controller/rtctrl/dispatcherv2.go:140–176  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

138}
139
140func (s *DispatchServerV2) statisticHandler(w http.ResponseWriter, r *http.Request) {
141 conn, _, ok := setupHijackConn(w, r)
142 if !ok {
143 return
144 }
145 defer conn.Close()
146 runtimeid := r.Header.Get("x-cfc-runtimeid")
147 nowstat := &statsConn{
148 name: runtimeid,
149 conn: conn,
150 memused: 0,
151 }
152 s.statsMap.set(runtimeid, nowstat)
153 defer s.statsMap.del(runtimeid, nowstat)
154
155 m, ok := s.storeMap.getMap(runtimeid)
156 if !ok {
157 logs.Errorf("statisticHandler can't get map runtimeid %s", runtimeid)
158 }
159 receiver := &statinfoReceiver{
160 name: runtimeid,
161 conn: conn,
162 }
163 receiver.Recv(func(info *statInfo) error {
164 if m != nil {
165 store, err := m.getLast()
166 if err != nil {
167 logs.Errorf("statisticHandler map %s can't get last request %s", m.String(), runtimeid)
168 }
169 if store != nil {
170 store.SetMemUsed(info.MemUsed)
171 }
172 }
173 nowstat.memused = info.MemUsed
174 return nil
175 })
176}
177
178func (s *DispatchServerV2) invokeHandler(w http.ResponseWriter, r *http.Request) {
179 conn, _, ok := setupHijackConn(w, r)

Callers 1

TestStatisticHandlerFunction · 0.95

Calls 11

RecvMethod · 0.95
ErrorfFunction · 0.92
setupHijackConnFunction · 0.85
getMapMethod · 0.80
getLastMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
StringMethod · 0.65
SetMemUsedMethod · 0.65
setMethod · 0.45
delMethod · 0.45

Tested by 1

TestStatisticHandlerFunction · 0.76