MCPcopy
hub / github.com/aceld/zinx / RouterRecovery

Function RouterRecovery

znet/defaultrouterfunc.go:32–47  ·  view source on GitHub ↗

This is used to store some default middlewares that can be used in RouterSlicesMode (用来存放一些RouterSlicesMode下的路由可用的默认中间件) RouterRecovery If you use the server obtained from initializing with NewDefaultRouterSlicesServer method, this function will be included. It is used to catch any panics that occur

(request ziface.IRequest)

Source from the content-addressed store, hash-verified

30// (如果使用NewDefaultRouterSlicesServer方法初始化的获得的server将自带这个函数
31// 作用是接收业务执行上产生的panic并且尝试记录现场信息)
32func RouterRecovery(request ziface.IRequest) {
33 defer func() {
34 if err := recover(); err != nil {
35 panicInfo := getInfo(StackBegin)
36 // Record the error
37 zlog.Ins().ErrorF("MsgId:%d Handler panic: info:%s err:%v", request.GetMsgID(), panicInfo, err)
38
39 //fmt.Printf("MsgId:%d Handler panic: info:%s err:%v", request.GetMsgID(), panicInfo, err)
40
41 // Should return an error (应该回传一个错误的)
42 //request.GetConnection().SendMsg()
43 }
44
45 }()
46 request.RouterSlicesNext()
47}
48
49// RouterTime Simply accumulates the time taken by all the routing groups, but not enabled
50// (简单累计所有路由组的耗时,不启用)

Callers

nothing calls this directly

Calls 5

InsFunction · 0.92
getInfoFunction · 0.85
ErrorFMethod · 0.65
GetMsgIDMethod · 0.65
RouterSlicesNextMethod · 0.65

Tested by

no test coverage detected