升级异常
This commit is contained in:
parent
8be5a85ed0
commit
e85811512f
@ -7,46 +7,6 @@
|
||||
// Date : 2021-04-01 6:38 下午
|
||||
package define
|
||||
|
||||
// NewError ...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 6:40 下午 2021/4/1
|
||||
func NewError(errType string, message string) *Error {
|
||||
return &Error{
|
||||
errType: errType,
|
||||
message: message,
|
||||
}
|
||||
}
|
||||
|
||||
// Error 定义异常
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 6:38 下午 2021/4/1
|
||||
type Error struct {
|
||||
errType string
|
||||
message string
|
||||
}
|
||||
|
||||
// Error 获取错误信息, 兼容内置 error 类型
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 6:39 下午 2021/4/1
|
||||
func (e Error) Error() string {
|
||||
return e.message
|
||||
}
|
||||
|
||||
// GetErrType 获取错误类型
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 6:42 下午 2021/4/1
|
||||
func (e Error) GetErrType() string {
|
||||
return e.errType
|
||||
}
|
||||
|
||||
const (
|
||||
// ErrorTypeNodeListEmpty 服务器节点列表为空
|
||||
ErrorTypeNodeListEmpty = "NODE_LIST_EMPTY"
|
||||
|
@ -7,7 +7,10 @@
|
||||
// Date : 2021-04-01 5:53 下午
|
||||
package dispatch
|
||||
|
||||
import "git.zhangdeman.cn/gateway/balance/define"
|
||||
import (
|
||||
"git.zhangdeman.cn/gateway/balance/define"
|
||||
"git.zhangdeman.cn/zhangdeman/exception"
|
||||
)
|
||||
|
||||
// IDispatch 负载均衡的接口定义
|
||||
//
|
||||
@ -16,5 +19,5 @@ import "git.zhangdeman.cn/gateway/balance/define"
|
||||
// Date : 2:44 下午 2021/4/1
|
||||
type IDispatch interface {
|
||||
// Get 获取一个节点
|
||||
Get(nodeList []*define.SeverNode) (string, *define.Error)
|
||||
Get(nodeList []*define.SeverNode) (string, exception.IException)
|
||||
}
|
||||
|
1
go.mod
1
go.mod
@ -8,6 +8,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
git.zhangdeman.cn/zhangdeman/exception v0.0.0-20250510123912-a0d52fc093ab // indirect
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mozillazg/go-pinyin v0.20.0 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -1,5 +1,7 @@
|
||||
git.zhangdeman.cn/zhangdeman/easylock v0.0.0-20230731062340-983985c12eda h1:bMD6r9gjRy7cO+T4zRQVYAesgIblBdTnhzT1vN5wjvI=
|
||||
git.zhangdeman.cn/zhangdeman/easylock v0.0.0-20230731062340-983985c12eda/go.mod h1:dT0rmHcJ9Z9IqWeMIt7YzR88nKkNV2V3dfG0j9Q6lK0=
|
||||
git.zhangdeman.cn/zhangdeman/exception v0.0.0-20250510123912-a0d52fc093ab h1:O0XaAKKb8qrjcjewonmKfnRsMFoCfJF+tUv6RfhRe94=
|
||||
git.zhangdeman.cn/zhangdeman/exception v0.0.0-20250510123912-a0d52fc093ab/go.mod h1:Voc8J4ordx7nuMWpgACXXZULQy7ZIuBzcEIoS8VnDIw=
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e h1:Q973S6CcWr1ICZhFI1STFOJ+KUImCl2BaIXm6YppBqI=
|
||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e/go.mod h1:VpPjBlwz8U+OxZuxzHQBv1aEEZ3pStH6bZvT21ADEbI=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"git.zhangdeman.cn/gateway/balance/define"
|
||||
"git.zhangdeman.cn/gateway/balance/dispatch"
|
||||
"git.zhangdeman.cn/zhangdeman/easylock"
|
||||
"git.zhangdeman.cn/zhangdeman/exception"
|
||||
)
|
||||
|
||||
// NewServer ...
|
||||
@ -73,7 +74,7 @@ func (s *Server) Remove(nodeID string) {
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 5:17 下午 2021/4/1
|
||||
func (s *Server) Get() (string, *define.Error) {
|
||||
func (s *Server) Get() (string, exception.IException) {
|
||||
_ = s.lock.RLock()
|
||||
defer func() {
|
||||
_ = s.lock.RUnlock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user