Documentation ¶
Index ¶
- Variables
- func GetAddress() string
- func GetDatacenter() string
- func GetDatacenters() ([]string, error)
- func GetFromPrefix(key string) (map[string][]byte, error)
- func GetNodeFromDC(dc *Datacenter) (*api.CatalogNode, error)
- func GetValue(key string) ([]byte, error)
- func GetValueByAllDatacenter(key string) (string, error)
- func PutValue(key string, value []byte) error
- func SetAddress(addr string)
- type Config
- type Datacenter
- func (dc *Datacenter) DeleteKey(key string) error
- func (dc *Datacenter) GetDatacenters() ([]string, error)
- func (dc *Datacenter) GetNode() (*api.CatalogNode, error)
- func (dc *Datacenter) GetPairs(key string) ([]Pair, error)
- func (dc *Datacenter) GetPairsFromPrefix(prefix string) (map[string][]byte, error)
- func (dc *Datacenter) GetPairsPrefix(prefix string) (map[string]string, error)
- func (dc *Datacenter) GetValue(key string) ([]byte, error)
- func (dc *Datacenter) PutValue(key string, value []byte) error
- type Pair
- type Service
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultDatacenter = NewDatacenter(discoverConfig.Datacenter)
默认为本地数据中心 - 一般局域网内只会访问本地的consul
Functions ¶
func GetAddress ¶
func GetAddress() string
func GetDatacenter ¶
func GetDatacenter() string
func GetDatacenters ¶
func GetNodeFromDC ¶
func GetNodeFromDC(dc *Datacenter) (*api.CatalogNode, error)
func GetValueByAllDatacenter ¶
func SetAddress ¶
func SetAddress(addr string)
Types ¶
type Datacenter ¶
type Datacenter struct { Name string // 数据中心名称,第一个数据中心默认:dc1 // contains filtered or unexported fields }
func GetDefaultDatacenter ¶
func GetDefaultDatacenter() *Datacenter
func NewDatacenter ¶
func NewDatacenter(name string) *Datacenter
func (*Datacenter) DeleteKey ¶
func (dc *Datacenter) DeleteKey(key string) error
从consul中删除key对应的value
func (*Datacenter) GetDatacenters ¶
func (dc *Datacenter) GetDatacenters() ([]string, error)
https://www.consul.io/api-docs/catalog#list-datacenters 获取多数据中心
func (*Datacenter) GetNode ¶
func (dc *Datacenter) GetNode() (*api.CatalogNode, error)
func (*Datacenter) GetPairsFromPrefix ¶
func (dc *Datacenter) GetPairsFromPrefix(prefix string) (map[string][]byte, error)
func (*Datacenter) GetPairsPrefix ¶
func (dc *Datacenter) GetPairsPrefix(prefix string) (map[string]string, error)
Click to show internal directories.
Click to hide internal directories.