Exemplo n.º 1
0
func (c *GremlinClient) Query(q string) ([]byte, error) {
	m, err := json.Marshal(gremlin.Query(q))
	if err != nil {
		return nil, err
	}

	c.Lock()
	defer c.Unlock()

	if err = c.sendMessage(string(m)); err != nil {
		return []byte{}, err
	}
	return gremlin.ReadResponse(c.wsConn)
}
Exemplo n.º 2
0
func (c *wsclient) query(q string) ([]byte, error) {
	m, err := json.Marshal(gremlin.Query(q))
	if err != nil {
		return nil, fmt.Errorf("Gremlin request error, %s: %s", q, err.Error())
	}

	c.Lock()
	defer c.Unlock()

	if err = c.sendMessage(string(m)); err != nil {
		return []byte{}, fmt.Errorf("Gremlin request error, %s: %s", q, err.Error())
	}

	b, err := gremlin.ReadResponse(c.wsConn)
	if err != nil {
		return []byte{}, fmt.Errorf("Gremlin request error, %s: %s", q, err.Error())
	}

	return b, nil
}