Documentation ¶
Index ¶
- Variables
- type ConnNameer
- type MsgDispatch
- func (r *MsgDispatch[Mr, Cr]) Dispatch(ctx context.Context, m Mr, c *Cr) bool
- func (r *MsgDispatch[Mr, Cr]) RegHook(f func(ctx context.Context, msgid string, elapsed time.Duration))
- func (md *MsgDispatch[Mr, Cr]) RegMsg(fun interface{})
- func (md *MsgDispatch[Mr, Cr]) RegReqResp(fun interface{})
- func (r *MsgDispatch[Mr, Cr]) WaitAllMsgDone(timeout time.Duration)
- type ParamConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ParamConf loader.JsonLoader[ParamConfig]
Functions ¶
This section is empty.
Types ¶
type MsgDispatch ¶
type MsgDispatch[Mr utils.RecvMsger, Cr any] struct { //【需要外部来设置】 // 必须设置,注册时获取具体消息的msgid RegMsgID func(msgType reflect.Type) string // 如果使用RegReqResp注册必须设置,用来发送Resp消息 SendResp func(ctx context.Context, m Mr, c *Cr, resp interface{}) // contains filtered or unexported fields }
MsgDispatch 提供消息注册和分发功能 Mr表示用来透传的消息指针类型,必须实现utils.RecvMsger接口 Cr表示用来透传的类型,一般为连接对象,可以选择实现ConnNameer接口,日志使用
func (*MsgDispatch[Mr, Cr]) Dispatch ¶
func (r *MsgDispatch[Mr, Cr]) Dispatch(ctx context.Context, m Mr, c *Cr) bool
消息分发
func (*MsgDispatch[Mr, Cr]) RegMsg ¶
func (md *MsgDispatch[Mr, Cr]) RegMsg(fun interface{})
注册消息处理函数 fun的参数支持以下写法 (ctx context.Context, msg *具体消息, c *Cr) (ctx context.Context, m *Mr, msg *具体消息, c *Cr)
func (*MsgDispatch[Mr, Cr]) RegReqResp ¶
func (md *MsgDispatch[Mr, Cr]) RegReqResp(fun interface{})
处理消息的函数参数是 fun的参数支持以下写法 (ctx context.Context, req *具体消息, resp *具体消息, c *Cr) (ctx context.Context, m Mr, req *具体消息, resp *具体消息, c *Cr)
func (*MsgDispatch[Mr, Cr]) WaitAllMsgDone ¶
func (r *MsgDispatch[Mr, Cr]) WaitAllMsgDone(timeout time.Duration)
type ParamConfig ¶
type ParamConfig struct { // 日志级别和zerolog.Level一致 LogLevelMsg int `json:"loglevelmsg,omitempty"` // msg消息默认的消息级别,不配置就是debug级别 LogLevelByMsg map[string]int `json:"loglevelbymsg,omitempty"` // 根据消息ID区分的消息日志级别,消息ID:日志级别,不配置就使用LogLevelMsg级别 TimeOutCheck int `json:"timeoutcheck,omitempty"` // 消息超时监控 单位秒 默认0不开启监控 // Timeout: 执行 command 的超时时间 单位为毫秒 // MaxConcurrentRequests: 最大并发量 // RequestVolumeThreshold: 一个统计窗口 10 秒内请求数量 达到这个请求数量后才去判断是否要开启熔断 // SleepWindow: 熔断器被打开后 SleepWindow的时间就是控制过多久后去尝试服务是否可用了 单位为毫秒 // ErrorPercentThreshold: 错误百分比 请求数量大于等于 RequestVolumeThreshold 并且错误率到达这个百分比后就会启动熔断 HystrixMsg map[string]*hystrix.CommandConfig `json:"hystrixmsg,omitempty"` // 熔断器 [msid:Config],目前不支持动态删除 }
参数配置
func (*ParamConfig) Create ¶
func (c *ParamConfig) Create()
func (*ParamConfig) IsHystrixMsg ¶
func (c *ParamConfig) IsHystrixMsg(msgid string) (string, bool)
func (*ParamConfig) MsgLogLevel ¶
func (c *ParamConfig) MsgLogLevel(msgid string) int
func (*ParamConfig) Normalize ¶
func (c *ParamConfig) Normalize()
Click to show internal directories.
Click to hide internal directories.