Documentation ¶
Index ¶
- Constants
- func CatalogServicesList(address string) (map[string][]string, error)
- func GetHealthNode(address string, service string) (nodes []string)
- func NewHTTPError(code int) error
- type AcquireReq
- type AgentCheck
- type Client
- func (c *Client) AcquireLock(name string, id string) (bool, error)
- func (c *Client) CatalogGetService(name string) (meta.Service, error)
- func (c *Client) CatalogListServices() ([]meta.Service, error)
- func (c *Client) Client() *consul.Client
- func (c *Client) CreateSession(name string) (string, error)
- func (c *Client) DeleteSession(id string) error
- func (c *Client) RefreshSession(id string) error
- func (c *Client) ReleaseLock(name string, id string) (bool, error)
- func (c *Client) ServiceDeregister(id string) error
- func (c *Client) ServiceRegister(parm consul.AgentServiceRegistration) error
- type ConsulRegistReq
- type CreateSessionReq
- type Option
- type Parm
- type RenewSessionRes
- type ServiceHealthCheck
- type ServiceHealthRes
- type ServiceHealthService
Constants ¶
View Source
const ( // SessionTTL session 的超时时间,主要用于在进程非正常退出后锁能够被动释放, // 同时在使用TTL后,进程需要间断renew session保活(推荐时间是ttl/2 SessionTTL = "10s" )
Variables ¶
This section is empty.
Functions ¶
func CatalogServicesList ¶
ServicesList 获取服务列表
func GetHealthNode ¶
GetHealthNode 获取service中的健康节点
func NewHTTPError ¶
NewHTTPError creates a new HTTPError instance.
Types ¶
type AcquireReq ¶
type AcquireReq struct {
Acquire string `json:"acquire"`
}
AcquireReq 获取锁请求 kv update
type AgentCheck ¶
type AgentCheck struct { Node string CheckID string Name string Status string Notes string Output string ServiceID string ServiceName string Type string Namespace string `json:",omitempty"` }
AgentCheck represents a check known to the agent
type Client ¶
func BuildWithOption ¶
func (*Client) CatalogGetService ¶
func (*Client) DeleteSession ¶
func (*Client) RefreshSession ¶
func (*Client) ServiceDeregister ¶
func (*Client) ServiceRegister ¶
func (c *Client) ServiceRegister(parm consul.AgentServiceRegistration) error
ServiceRegister 服务注册
https://developer.hashicorp.com/consul/api-docs/agent/service#register-service
type ConsulRegistReq ¶
type ConsulRegistReq struct { ID string `json:"ID"` Name string `json:"Name"` Tags []string `json:"Tags"` Address string `json:"Address"` Port int `json:"Port"` }
ConsulRegistReq regist req dat
type CreateSessionReq ¶
CreateSessionReq new session dat
type Option ¶
type Option func(*Parm)
func WithAddress ¶
func WithAllowStale ¶
func WithConfig ¶
func WithQueryOption ¶
func WithQueryOption(opt *consul.QueryOptions) Option
func WithTimeOut ¶
type RenewSessionRes ¶
type RenewSessionRes struct { ID string `json:"ID"` Name string `json:"Name"` TTL string `json:"TTL"` CreateIndex string `json:"CreateIndex"` ModifyIndex string `json:"ModifyIndex"` }
RenewSessionRes renew
type ServiceHealthCheck ¶
type ServiceHealthCheck struct { ID string `json:"ID"` Node string `json:"Node"` Name string `josn:"Name"` Status string `json:"Status"` // passing ServiceID string `json:"ServiceID"` ServiceName string `json:"ServiceName"` }
ServiceHealthCheck 节点健康检查 check
type ServiceHealthRes ¶
type ServiceHealthRes struct { Checks []ServiceHealthCheck Service ServiceHealthService }
ServiceHealthRes 节点健康检查返回
type ServiceHealthService ¶
type ServiceHealthService struct { ID string `json:"ID"` Service string `json:"Service"` Address string `json:"Address"` }
ServiceHealthService 节点健康检查 service
Click to show internal directories.
Click to hide internal directories.