consul

package
v1.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHost = "consulx.com:8500"
)

Functions

func TimeoutCoder

func TimeoutCoder(f func(interface{}) error, e interface{}, msg string) error

Types

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
}

Consulx配置参数

type ConsulManager

type ConsulManager struct {
	Host    string
	Consulx *consulapi.Client
	Config  *ConsulConfig
}

func (*ConsulManager) AddRegistration

func (self *ConsulManager) AddRegistration(name string, iface interface{})

中心注册接口服务

func (*ConsulManager) CallService

func (self *ConsulManager) CallService(srv string, args interface{}, reply interface{}) error

获取RPC服务,并执行访问 args参数不可变,reply参数可变

func (*ConsulManager) Client

func (self *ConsulManager) Client(dsname ...string) (*ConsulManager, error)

func (*ConsulManager) GetKV

func (self *ConsulManager) GetKV(key string, consulx ...*consulapi.Client) ([]byte, error)

通过Consul中心获取指定配置数据

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) StartListenAndServe

func (self *ConsulManager) StartListenAndServe()

开启并监听服务

type MonitorLog

type MonitorLog struct {
	ConsulHost  string
	RpcHost     string
	RpcPort     int
	Protocol    string
	ServiceName string
	MethodName  string
	BeginTime   int64
	CostTime    int64
	Errors      []string
}

RPC日志

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL