isucon-library

module
v0.0.0-...-431d825 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2021 License: MIT

README

isucon-library

isucon go library

Directories

Path Synopsis
INSTRUCTION: Put the following code in initialize() logid := GetNextLogID() StartLogger(logid) It is possible to add user defined regions for trace by adding: defer trace.StartRegion(context.Background(), regionName).End() For example, in order to add it to every handler of http, one can write a wrapper as follows: handleFunc := func(p goji.Pattern, h func(http.ResponseWriter, *http.Request)) { regionName := GetFunctionName(h) mux.HandleFunc(p, func(a http.ResponseWriter, b *http.Request) { defer trace.StartRegion(context.Background(), regionName).End() h(a, b) }) } If you are using echo, the following code works: func TraceMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { defer trace.StartRegion(c.Request().Context(), c.Request().Method + " " + c.Path()).End() return next(c) } } func main() { e := echo.New() // ...
INSTRUCTION: Put the following code in initialize() logid := GetNextLogID() StartLogger(logid) It is possible to add user defined regions for trace by adding: defer trace.StartRegion(context.Background(), regionName).End() For example, in order to add it to every handler of http, one can write a wrapper as follows: handleFunc := func(p goji.Pattern, h func(http.ResponseWriter, *http.Request)) { regionName := GetFunctionName(h) mux.HandleFunc(p, func(a http.ResponseWriter, b *http.Request) { defer trace.StartRegion(context.Background(), regionName).End() h(a, b) }) } If you are using echo, the following code works: func TraceMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { defer trace.StartRegion(c.Request().Context(), c.Request().Method + " " + c.Path()).End() return next(c) } } func main() { e := echo.New() // ...
Example: var group = rpcgroup.New(5000, "app1:5000", "app2:5000") func init() { id := "0001" group.Call(InitializeFunction, id) } var InitializeFunction = rpcgroup.Register(func(id string) { StartLogger(id) })
Example: var group = rpcgroup.New(5000, "app1:5000", "app2:5000") func init() { id := "0001" group.Call(InitializeFunction, id) } var InitializeFunction = rpcgroup.Register(func(id string) { StartLogger(id) })

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL