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

Method invokeHandler

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

Source from the content-addressed store, hash-verified

176}
177
178func (s *DispatchServerV2) invokeHandler(w http.ResponseWriter, r *http.Request) {
179 conn, _, ok := setupHijackConn(w, r)
180 if !ok {
181 logs.Error("setupHijackConn failed")
182 return
183 }
184 defer conn.Close()
185
186 runtimeid := r.Header.Get("x-cfc-runtimeid")
187 commitid := r.Header.Get("x-cfc-commitid")
188 // TODO: [improve] hostip here is always 127.0.0.1
189 hostip := r.Header.Get("x-cfc-hostip")
190 logs.V(6).Infof("runtime %s@%s connect", runtimeid, hostip)
191
192 runtime, err := s.runtimeDispatcher.GetRuntime(runtimeid)
193 if err != nil {
194 logs.V(3).Errorf("runtime %s not found", runtimeid)
195 return
196 }
197
198 warmNotify := make(chan struct{})
199 params := &startRuntimeParams{
200 commitID: commitid,
201 hostIP: hostip,
202 conn: conn,
203 warmNotify: warmNotify,
204 urlParams: r.URL.Query(),
205 }
206 go func() {
207 select {
208 case <-warmNotify:
209 logs.V(9).Infof("[resource modify]-[increase]: runtime %s, resource %s", runtime.RuntimeID, runtime.Resource)
210 s.runtimeDispatcher.IncreaseUsedResource(runtime.Resource)
211 }
212 }()
213 if err := runtime.startRuntimeLoop(params); err != nil {
214 logs.Errorf("init runtime %s failed: %s", runtime.RuntimeID, err.Error())
215 return
216 }
217}
218
219func (s *DispatchServerV2) runnerHandler(w http.ResponseWriter, r *http.Request) {
220 runtimeID := r.Header.Get("x-cfc-runtimeid")

Callers 2

TestInvokeHandlerFunction · 0.95
initRuntimeFunction · 0.80

Calls 12

ErrorFunction · 0.92
VFunction · 0.92
ErrorfFunction · 0.92
setupHijackConnFunction · 0.85
InfofMethod · 0.80
ErrorfMethod · 0.80
startRuntimeLoopMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
GetRuntimeMethod · 0.65
IncreaseUsedResourceMethod · 0.65
ErrorMethod · 0.45

Tested by 2

TestInvokeHandlerFunction · 0.76
initRuntimeFunction · 0.64