Documentation ¶
Index ¶
- Constants
- Variables
- func Md5Encode(data string) string
- type Config
- type Consistent
- type Param
- type Register
- func (r *Register) Config(groupName string) *configBuild
- func (r *Register) GetService(groupName string, name string, mode int) (*Service, bool)
- func (r *Register) GetServiceAddrByHash(groupName string, name string, hash string) (string, bool)
- func (r *Register) Listen()
- func (r *Register) Register(groupName string, name string, addr string) *Register
- func (r *Register) Rpc(groupName string, name string) *rpcRequestBuild
- func (r *Register) SetOnline(online bool, imEf bool)
- func (r *Register) UseService(use map[string][]string) *Register
- type RequestServer
- type Service
Constants ¶
View Source
const ( Rand = iota //随机 Poll //轮询 Only //只请求第一个 )
Variables ¶
View Source
var ( OnlineStatus = true OnlineStatusLock sync.RWMutex )
Functions ¶
Types ¶
type Config ¶
type Config struct { AppName string `json:"app_name"` EnvName string `json:"env_name"` GroupName string `json:"group_name"` Name string `json:"name"` Content string `json:"content"` Hash string `json:"hash"` Type string `json:"type"` Status int `json:"status"` // contains filtered or unexported fields }
Config 配置结构体
type Consistent ¶
type Consistent struct { //虚拟节点个数,用来增加hash的平衡性 VirtualNode int //map 读写锁 sync.RWMutex // contains filtered or unexported fields }
Consistent 创建结构体保存一致性hash信息
type Register ¶
type Register struct { Servers string `json:"-"` //注册中心 TokenName string `json:"-"` //通信密匙名称 Token string `json:"-"` //通信密匙 Name string `json:"name"` //服务名称 AppName string `json:"app_name"` //所属应用 EnvName string `json:"env_name"` //环境标识 GroupName string `json:"group_name"` //分组名称 Addr string `json:"addr"` //服务地址(规则ip:port) // contains filtered or unexported fields }
Register 注册中心
func (*Register) GetService ¶
GetService 获取随机节点(负载均衡)
func (*Register) GetServiceAddrByHash ¶
GetServiceAddrByHash 通过hash获取service
type RequestServer ¶
type Service ¶
type Service struct { Name string `json:"name"` AppName string `json:"app_name"` EnvName string `json:"env_name"` GroupName string `json:"group_name"` Addr string `json:"addr"` ServiceHash string `json:"service_hash"` LastHeartTime int64 `json:"last_heart_time"` Status int `json:"status"` }
Service 服务列表
Click to show internal directories.
Click to hide internal directories.