Documentation ¶
Index ¶
- Variables
- func TimeoutCoder(f func(interface{}) error, e interface{}, msg string) error
- type CallInfo
- type ConsulConfig
- type ConsulManager
- func (self *ConsulManager) AddRPC(callInfo ...*CallInfo)
- func (self *ConsulManager) AddRegistration(name string, iface interface{}, ipname ...string)
- func (self *ConsulManager) CallRPC(callInfo *CallInfo) error
- func (self *ConsulManager) CallService(srv string, args interface{}, reply interface{}) error
- func (self *ConsulManager) ClearTagService(tag string)
- func (self *ConsulManager) Client(dsname ...string) (*ConsulManager, error)
- func (self *ConsulManager) GetAllService(service string) ([]*consulapi.AgentService, error)
- func (self *ConsulManager) GetHealthService(service string) ([]*consulapi.ServiceEntry, error)
- func (self *ConsulManager) GetKV(key string, consulx ...*consulapi.Client) ([]byte, error)
- func (self *ConsulManager) InitConfig(input ...ConsulConfig) (*ConsulManager, error)
- func (self *ConsulManager) ReadJsonConfig(node string, result interface{}) error
- func (self *ConsulManager) RemoveService(serviceIDs ...string)
- func (self *ConsulManager) StartListenAndServe()
- type MonitorLog
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DefaultHost = "consulx.com:8500"
)
Functions ¶
func TimeoutCoder ¶
Types ¶
type CallInfo ¶ added in v1.0.40
type CallInfo struct { Tags []string // 服务标签名称 Domain string // 自定义访问域名,为空时自动填充内网IP Iface interface{} // 接口实现类实例 Package string // RPC服务包名 Service string // RPC服务名称 Method string // RPC方法名称 Protocol string // RPC访问协议,默认TCP Request interface{} // 请求参数对象 Response interface{} // 响应参数对象 Timeout int64 // 连接请求超时,默认10秒 }
RPC参数对象
type ConsulConfig ¶
type ConsulConfig struct { DsName string Node string Host string Domain string CheckPort int RpcPort int ListenProt int Protocol string Logger string Timeout string Interval string DestroyAfter string SlowQuery int64 // 0.不开启筛选 >0开启筛选查询 毫秒 SlowLogPath string // 慢查询写入地址 }
Consulx配置参数
type ConsulManager ¶
type ConsulManager struct { Host string Consulx *consulapi.Client Config *ConsulConfig Selection func([]*consulapi.ServiceEntry) *consulapi.ServiceEntry }
func (*ConsulManager) AddRPC ¶ added in v1.0.40
func (self *ConsulManager) AddRPC(callInfo ...*CallInfo)
中心注册接口服务
func (*ConsulManager) AddRegistration ¶
func (self *ConsulManager) AddRegistration(name string, iface interface{}, ipname ...string)
中心注册接口服务
func (*ConsulManager) CallRPC ¶ added in v1.0.40
func (self *ConsulManager) CallRPC(callInfo *CallInfo) error
获取RPC服务,并执行访问 args参数不可变,reply参数可变
func (*ConsulManager) CallService ¶
func (self *ConsulManager) CallService(srv string, args interface{}, reply interface{}) error
获取RPC服务,并执行访问 args参数不可变,reply参数可变
func (*ConsulManager) ClearTagService ¶ added in v1.0.52
func (self *ConsulManager) ClearTagService(tag string)
func (*ConsulManager) Client ¶
func (self *ConsulManager) Client(dsname ...string) (*ConsulManager, error)
func (*ConsulManager) GetAllService ¶ added in v1.0.42
func (self *ConsulManager) GetAllService(service string) ([]*consulapi.AgentService, error)
根据服务名获取可用列表
func (*ConsulManager) GetHealthService ¶ added in v1.0.42
func (self *ConsulManager) GetHealthService(service string) ([]*consulapi.ServiceEntry, error)
func (*ConsulManager) InitConfig ¶
func (self *ConsulManager) InitConfig(input ...ConsulConfig) (*ConsulManager, error)
func (*ConsulManager) ReadJsonConfig ¶
func (self *ConsulManager) ReadJsonConfig(node string, result interface{}) error
读取节点JSON配置
func (*ConsulManager) RemoveService ¶ added in v1.0.40
func (self *ConsulManager) RemoveService(serviceIDs ...string)
func (*ConsulManager) StartListenAndServe ¶
func (self *ConsulManager) StartListenAndServe()
开启并监听服务
Click to show internal directories.
Click to hide internal directories.