示例#1
0
文件: etcd.go 项目: davemkirk/vulcand
func (n *ng) GetServer(sk engine.ServerKey) (*engine.Server, error) {
	bytes, err := n.getVal(n.path("backends", sk.BackendKey.Id, "servers", sk.Id))
	if err != nil {
		return nil, err
	}
	return engine.ServerFromJSON([]byte(bytes), sk.Id)
}
示例#2
0
func (c *Client) GetServer(sk engine.ServerKey) (*engine.Server, error) {
	data, err := c.Get(c.endpoint("backends", sk.BackendKey.Id, "servers", sk.Id), url.Values{})
	if err != nil {
		return nil, err
	}
	return engine.ServerFromJSON(data)
}
示例#3
0
文件: api.go 项目: davemkirk/vulcand
func parseServerPack(v []byte) (*engine.Server, time.Duration, error) {
	var sp serverReadPack
	if err := json.Unmarshal(v, &sp); err != nil {
		return nil, 0, err
	}
	if len(sp.Server) == 0 {
		return nil, 0, &scroll.MissingFieldError{Field: "Server"}
	}
	s, err := engine.ServerFromJSON(sp.Server)
	if err != nil {
		return nil, 0, err
	}
	var ttl time.Duration
	if sp.TTL != "" {
		ttl, err = time.ParseDuration(sp.TTL)
		if err != nil {
			return nil, 0, err
		}
	}
	return s, ttl, nil
}