Documentation ¶
Index ¶
- Constants
- Variables
- func ReadTxt(c *ConsulOperator, file string) ([]byte, error)
- type ConsulApp
- func NewApp(healthHost, agent string) (*ConsulApp, error)
- func NewAppWithCfg(cfg interface{}, healthHost string) (*ConsulApp, error)
- func NewAppWithCfgEx(cfg interface{}, healthHost, consulUrl string) (*ConsulApp, error)
- func NewAppWithCustomCfg(cfg interface{}, confName, healthHost string) (*ConsulApp, error)
- type ConsulAppInfo
- type ConsulOperator
- func (c *ConsulOperator) Acquire(key string, stopChan <-chan struct{}) error
- func (c *ConsulOperator) Delete(name string) error
- func (c *ConsulOperator) DeregisterService() error
- func (c *ConsulOperator) Fix()
- func (c *ConsulOperator) Get(name string) ([]byte, error)
- func (c *ConsulOperator) GetEx(name string) ([]byte, uint64, error)
- func (c *ConsulOperator) ListService(name string) ([]*consulapi.CatalogService, error)
- func (c *ConsulOperator) ListServices() (map[string][]string, error)
- func (c *ConsulOperator) Ping() error
- func (c *ConsulOperator) PrintServices(name string) error
- func (c *ConsulOperator) Put(name string, value []byte) error
- func (c *ConsulOperator) RegisterService() error
- func (c *ConsulOperator) Release(key string) error
Constants ¶
const (
CONSUL_HEALTH_PATH = "health"
)
Variables ¶
var (
ErrNotExist = errors.New("NOT EXIST")
)
Functions ¶
Types ¶
type ConsulApp ¶
type ConsulApp struct {
*ConsulOperator
}
func NewApp ¶
create a consul app arg heathHost is must parameter, a health http address of app arg agent is option, if empty using default 127.0.0.1:8500
func NewAppWithCfg ¶
create a consul app with load cfg, using 127.0.0.1:8500 cfg is required parameter, the cfg address arg heathHost is must parameter, a health http address of app
func NewAppWithCfgEx ¶
create a consul app with load cfg, using 127.0.0.1:8500 cfg is required parameter, the cfg address arg heathHost is must parameter, a health http address of app arg consulUrl is an FQDN format string which contains consul host,port,configpath, if configpath is empty, ${appname}.yml, config/${appname} will be tried to load in order
func NewAppWithCustomCfg ¶
create a consul app with load cfg, using 127.0.0.1:8500 cfg is required parameter, the cfg address arg heathHost is must parameter, a health http address of app arg consulUrl is an FQDN format string which contains consul host,port,configpath
type ConsulAppInfo ¶
type ConsulAppInfo struct { ConsulHost string `json:"consul_host" yaml:"consul_host"` ConsulPort int `json:"consul_port" yaml:"consul_port"` Config string `json:"config" yaml:"config"` Values url.Values `json:"values" yaml:"values"` CheckInterval string `json:"check_interval" yaml:"check_interval"` CheckHTTP string `json:"check_http" yaml:"check_http"` CheckTCP string `json:"check_tcp" yaml:"check_tcp"` }
func ParseConsulUrl ¶
func ParseConsulUrl(consulUrl string) (*ConsulAppInfo, error)
type ConsulOperator ¶
type ConsulOperator struct { Agent string `json:"agent,omitempty" yaml:"agent,omitempty"` IP string `json:"ip" yaml:"ip"` Port int `json:"port" yaml:"port"` Name string `json:"Name" yaml:"Name"` Path string `json:"path,omitempty" yaml:"path,omitempty"` Interval string `json:"interval,omitempty" yaml:"interval,omitempty"` // contains filtered or unexported fields }
func NewConsulOp ¶
func NewConsulOp(agent string) *ConsulOperator
func (*ConsulOperator) Acquire ¶
func (c *ConsulOperator) Acquire(key string, stopChan <-chan struct{}) error
func (*ConsulOperator) Delete ¶
func (c *ConsulOperator) Delete(name string) error
func (*ConsulOperator) DeregisterService ¶
func (c *ConsulOperator) DeregisterService() error
func (*ConsulOperator) Fix ¶
func (c *ConsulOperator) Fix()
func (*ConsulOperator) ListService ¶
func (c *ConsulOperator) ListService(name string) ([]*consulapi.CatalogService, error)
func (*ConsulOperator) ListServices ¶
func (c *ConsulOperator) ListServices() (map[string][]string, error)
func (*ConsulOperator) Ping ¶
func (c *ConsulOperator) Ping() error
func (*ConsulOperator) PrintServices ¶
func (c *ConsulOperator) PrintServices(name string) error
func (*ConsulOperator) RegisterService ¶
func (c *ConsulOperator) RegisterService() error
func (*ConsulOperator) Release ¶
func (c *ConsulOperator) Release(key string) error