mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-23 10:50:24 +08:00
fix 修复潜在索引越限问题
This commit is contained in:
parent
dc20a86b33
commit
817482bedb
@ -75,7 +75,9 @@ func GenHashOption(key interface{}, label string) *model.Option {
|
|||||||
tag := "default"
|
tag := "default"
|
||||||
if _, err := hash.Write(gconv.Bytes(label)); err == nil {
|
if _, err := hash.Write(gconv.Bytes(label)); err == nil {
|
||||||
index := int(hash.Sum32()) % len(strings)
|
index := int(hash.Sum32()) % len(strings)
|
||||||
tag = strings[index]
|
if index < len(strings) {
|
||||||
|
tag = strings[index]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &model.Option{
|
return &model.Option{
|
||||||
Key: key,
|
Key: key,
|
||||||
|
@ -89,7 +89,7 @@ func (m *MsgParser) RegisterRPCRouter(routers ...interface{}) (err error) {
|
|||||||
|
|
||||||
// RegisterInterceptor 注册拦截器
|
// RegisterInterceptor 注册拦截器
|
||||||
func (m *MsgParser) RegisterInterceptor(interceptors ...Interceptor) {
|
func (m *MsgParser) RegisterInterceptor(interceptors ...Interceptor) {
|
||||||
m.interceptors = append(interceptors, interceptors...)
|
m.interceptors = append(m.interceptors, interceptors...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encoding 消息编码
|
// Encoding 消息编码
|
||||||
|
Loading…
Reference in New Issue
Block a user