Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GCI ¶
func GCI(next http.HandlerFunc) http.HandlerFunc
GCI returns the GCI HTTP handler, which controls Go's GC to decrease service tail latency. Ideally, GCI handler should be the first middleware in the service process chain.
Example ¶
f := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hi") }) ts := httptest.NewServer(GCI(f)) defer ts.Close() // Usual serving flow. res, err := http.Get(ts.URL) if err != nil { panic(err) } b, err := ioutil.ReadAll(res.Body) res.Body.Close() if err != nil { panic(err) } fmt.Print(string(b))
Output: ==< Automatic GC Disabled <== Hi
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.