Documentation ¶
Index ¶
- Constants
- func WatchKey(consulAddr, key string, handle func(*api.KVPair))
- func WatchKeyPrefix(consulAddr, key string, handle func(api.KVPairs))
- type Client
- func (client *Client) Deregister() error
- func (client *Client) Get(key string) (string, error)
- func (client *Client) GetArray(keyPrefix string) ([]string, error)
- func (client *Client) GetChildKeys(keyPrefix string) ([]string, error)
- func (client *Client) GetChildValues(keyPrefix string) (api.KVPairs, error)
- func (client *Client) GetFloat64(key string) (float64, error)
- func (client *Client) GetHostPort(key string) (string, string, error)
- func (client *Client) GetInt(key string) (int, error)
- func (client Client) GetInt64(key string) (int64, error)
- func (client *Client) GetMap(keyPrefix string) (map[string]string, error)
- func (client Client) GetOrDefault(key, defaultValue string) string
- func (client Client) GetOrDefaultInt64(key string, defaultValue int64) int64
- func (client *Client) GetUriAndFunctionIDs(serviceName string) (map[string]string, error)
- func (client *Client) GetValues(keys []string) (api.KVPairs, error)
- func (client *Client) KV() *api.KV
- func (client *Client) Put(key, value string) error
- type ClientOptionFunc
- func SetAddress(address string) ClientOptionFunc
- func SetDatacenter(datacenter string) ClientOptionFunc
- func SetHttpBasicAuth(userName, password string) ClientOptionFunc
- func SetRegister(reg *api.AgentServiceRegistration) ClientOptionFunc
- func SetScheme(scheme string) ClientOptionFunc
- func SetToken(token string) ClientOptionFunc
- func SetWaitTime(waitTime time.Duration) ClientOptionFunc
Constants ¶
View Source
const ( ErrorKeyNotExist = "Key(%s) does not exist" ErrorDirNotExist = "Dir(%s) does not exist" )
View Source
const FunctionIDsTmpl = "service/go/%s/functionids"
Variables ¶
This section is empty.
Functions ¶
func WatchKeyPrefix ¶
WatchKeyPrefix 监听某一级目录下所有key变化 监听到变化会调用handle,参数为变化key的相关信息 TODO 需要提供stop?
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientOptionFunc) (*Client, error)
func (*Client) Deregister ¶
func (*Client) GetArray ¶
GetArray
例如 key value conn/mongodb/goimhistory/1 172.16.9.221:27017 conn/mongodb/goimhistory/2 172.16.9.222:27017 keyPrefix=conn/mongodb/goimhistory/ return ["172.16.9.221:27017","172.16.9.222:27017"]
func (*Client) GetChildKeys ¶
GetChildKeys 获取下一级所有key
func (*Client) GetChildValues ¶
GetChildValues 获取下一级所有key的值 TODO 如果下一级key也是目录?
func (*Client) GetMap ¶
GetMap 例如
key value conn/redis/config/master/1/db 0 conn/redis/config/master/1/ip 172.16.9.221 conn/redis/config/master/1/poolsize 1 conn/redis/config/master/1/port 6379 keyPrefix=conn/redis/config/master/1/ return map[db:0 ip:172.16.9.221 poolsize:1 port:6379]
func (Client) GetOrDefault ¶
GetOrDefault 获取指定key的值,没有就返回缺省值
func (Client) GetOrDefaultInt64 ¶
GetOrDefaultInt64 获取指定key的int64值,没有就返回缺省值
func (*Client) GetUriAndFunctionIDs ¶
GetFunctionIDs 获取服务所有权限function id和对应的uri
type ClientOptionFunc ¶
func SetAddress ¶
func SetAddress(address string) ClientOptionFunc
func SetDatacenter ¶
func SetDatacenter(datacenter string) ClientOptionFunc
func SetHttpBasicAuth ¶
func SetHttpBasicAuth(userName, password string) ClientOptionFunc
func SetRegister ¶
func SetRegister(reg *api.AgentServiceRegistration) ClientOptionFunc
func SetScheme ¶
func SetScheme(scheme string) ClientOptionFunc
func SetToken ¶
func SetToken(token string) ClientOptionFunc
func SetWaitTime ¶
func SetWaitTime(waitTime time.Duration) ClientOptionFunc
Click to show internal directories.
Click to hide internal directories.