Beispiel #1
0
func (c *Client) GetListener(lk engine.ListenerKey) (*engine.Listener, error) {
	data, err := c.Get(c.endpoint("listeners", lk.Id), url.Values{})
	if err != nil {
		return nil, err
	}
	return engine.ListenerFromJSON(data)
}
Beispiel #2
0
func parseListenerPack(v []byte) (*engine.Listener, error) {
	var lp listenerReadPack
	if err := json.Unmarshal(v, &lp); err != nil {
		return nil, err
	}
	if len(lp.Listener) == 0 {
		return nil, &scroll.MissingFieldError{Field: "Listener"}
	}
	return engine.ListenerFromJSON(lp.Listener)
}
Beispiel #3
0
func (n *ng) GetListener(key engine.ListenerKey) (*engine.Listener, error) {
	bytes, err := n.getVal(n.path("listeners", key.Id))
	if err != nil {
		return nil, err
	}
	l, err := engine.ListenerFromJSON([]byte(bytes), key.Id)
	if err != nil {
		return nil, err
	}
	return l, nil
}
Beispiel #4
0
func (n *ng) parseListeners(node *etcd.Node) ([]engine.Listener, error) {
	listeners := make([]engine.Listener, len(node.Nodes))
	for idx, node := range node.Nodes {
		listenerId := suffix(node.Key)
		listener, err := engine.ListenerFromJSON([]byte(node.Value), listenerId)
		if err != nil {
			return nil, err
		}
		listeners[idx] = *listener
	}
	return listeners, nil
}
Beispiel #5
0
func (n *ng) parseListeners(keyValues []*mvccpb.KeyValue) ([]engine.Listener, error) {
	listeners := []engine.Listener{}
	for _, keyValue := range keyValues {
		if listenerIds := listenerIdRegex.FindStringSubmatch(string(keyValue.Key)); len(listenerIds) == 2 {
			listenerId := listenerIds[1]

			listener, err := engine.ListenerFromJSON([]byte(keyValue.Value), listenerId)
			if err != nil {
				return nil, err
			}
			listeners = append(listeners, *listener)
		}
	}
	return listeners, nil
}