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

Method ServeHTTP

pkg/server/filters/timeout.go:75–95  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

73}
74
75func (t *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
76 after, recordFn, err := t.timeout(r)
77 if after == nil {
78 t.handler.ServeHTTP(w, r)
79 return
80 }
81
82 done := make(chan struct{})
83 tw := newTimeoutWriter(w)
84 go func() {
85 t.handler.ServeHTTP(tw, r)
86 close(done)
87 }()
88 select {
89 case <-done:
90 case <-after.C:
91 recordFn()
92 tw.timeout(err)
93 }
94 after.Stop()
95}
96
97type timeoutWriter interface {
98 http.ResponseWriter

Callers 4

WithMaxInFlightLimitFunction · 0.45
WithWaitGroupFunction · 0.45
WithRequestIDFunction · 0.45

Calls 2

newTimeoutWriterFunction · 0.85
timeoutMethod · 0.65

Tested by

no test coverage detected