// Do executes the delete-by-query operation.
514882
func (s *DeleteByQueryService) Do() (*DeleteByQueryResult, error) {
	var err error

	// Build url
	path := "/"

	// Indices part
	indexPart := make([]string, 0)
	for _, index := range s.indices {
		index, err = uritemplates.Expand("{index}", map[string]string{
			"index": index,
		})
		if err != nil {
			return nil, err
		}
		indexPart = append(indexPart, index)
	}
	if len(indexPart) > 0 {
		path += strings.Join(indexPart, ",")
	}

	// Types part
	typesPart := make([]string, 0)
	for _, typ := range s.types {
		typ, err = uritemplates.Expand("{type}", map[string]string{
			"type": typ,
		})
		if err != nil {
			return nil, err
		}
		typesPart = append(typesPart, typ)
	}
	if len(typesPart) > 0 {
		path += "/" + strings.Join(typesPart, ",")
	}

	// Search
	path += "/_query"

	// Parameters
	params := make(url.Values)
	if s.analyzer != "" {
		params.Set("analyzer", s.analyzer)
	}
	if s.consistency != "" {
		params.Set("consistency", s.consistency)
	}
	if s.defaultOper != "" {
		params.Set("default_operator", s.defaultOper)
	}
	if s.df != "" {
		params.Set("df", s.df)
	}
	if s.ignoreUnavailable != nil {
		params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
	}
	if s.allowNoIndices != nil {
		params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
	}
	if s.expandWildcards != "" {
		params.Set("expand_wildcards", s.expandWildcards)
	}
	if s.replication != "" {
		params.Set("replication", s.replication)
	}
	if s.routing != "" {
		params.Set("routing", s.routing)
	}
	if s.timeout != "" {
		params.Set("timeout", s.timeout)
	}
	if s.pretty {
		params.Set("pretty", fmt.Sprintf("%v", s.pretty))
	}
	if s.q != "" {
		params.Set("q", s.q)
	}

	// Set body if there is a query set
	var body interface{}
	if s.query != nil {
		query := make(map[string]interface{})
		query["query"] = s.query.Source()
		body = query
	}

	// Get response
	res, err := s.client.PerformRequest("DELETE", path, params, body)
	if err != nil {
		return nil, err
	}

	// Return result
	ret := new(DeleteByQueryResult)
	if err := json.Unmarshal(res.Body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}
1185692
func (c *Client) do(action string, params *url.Values, v *Response) error {
	// https://api.linode.com/?api_key={key}&api_action=test.echo&foo=bar
	if params == nil {
		params = &url.Values{}
	}
	params.Add("api_key", c.ApiKey)
	params.Add("api_action", action)
	return c.request(params, v)
}
162026
func (rc *Redis) do(commandName string, args ...interface{}) (reply interface{}, err error) {
	if rc.p == nil {
		rc.connectInit()
	}
	c := rc.p.Get()
	defer c.Close()

	return c.Do(commandName, args...)
}
1337621
func (c *Client) do(req *http.Request, v interface{}) (*http.Response, error) {
	resp, err := c.client.Do(req)
	if err != nil {
		return nil, err
	}

	defer resp.Body.Close()

	if status := resp.StatusCode; status < 200 || status > 299 {
		return resp, RegistryError{Code: status, method: req.Method, url: req.URL}
	}

	if v != nil {
		if writer, ok := v.(io.Writer); ok {
			io.Copy(writer, resp.Body)
		} else {
			err = json.NewDecoder(resp.Body).Decode(v)
		}
	}

	return resp, err
}
397387
func (d RequestDoerFunc) Do(req *http.Request) (*http.Response, error) {
	return d(req)
}
1038918
func (b *BaseBuilder) Delete(table string, where Expression) *Query {
	sql := "DELETE FROM " + b.db.QuoteTableName(table)
	params := Params{}
	if where != nil {
		w := where.Build(b.db, params)
		if w != "" {
			sql += " WHERE " + w
		}
	}
	return b.NewQuery(sql).Bind(params)
}
917846
func (r *RequestConfig) Do(block func(config *RequestConfig)) *RequestConfig {
	block(r)
	return r
}
1369652
func (conn *Connection) Do(cmd string, args ...interface{}) (*ResultSet, error) {
	cmd = strings.ToLower(cmd)
	if strings.Contains(cmd, "subscribe") {
		return nil, errors.New(ErrUseSubscription, errorMessages)
	}
	err := conn.ensureProtocol()
	if err != nil {
		return nil, err
	}
	if conn.database.monitoring {
		m := monitoring.BeginMeasuring(identifier.Identifier("redis", "command", cmd))
		defer m.EndMeasuring()
	}
	err = conn.resp.sendCommand(cmd, args...)
	logCommand(cmd, args, err, conn.database.logging)
	if err != nil {
		return nil, err
	}
	result, err := conn.resp.receiveResultSet()
	return result, err
}
1036071
func (rt *DefaultRequestDoer) Do(ctx context.Context, r *http.Request,
	v interface{}) (*http.Response, error) {

	resp, err := rt.Client.Do(r)
	if err != nil {
		return nil, err
	}

	defer resp.Body.Close()

	err = checkResponseCode(resp)
	if err != nil {
		return resp, err
	}

	if v != nil {
		dec := json.NewDecoder(resp.Body)
		err = dec.Decode(v)
		if err != nil {
			return nil, err
		}
	}

	return resp, nil
}
220495
func Do(fn Func) error {
	var err error
	var cont bool
	attempt := 1
	for {
		cont, err = fn(attempt)
		if !cont || err == nil {
			break
		}
		attempt++
		if attempt > MaxRetries {
			return errMaxRetriesReached
		}
	}
	return err
}
527574
func (d *Do) do() {
	for {
		// Check context
		if d.ctx.Err() != nil {
			return
		}

		// Lock cond here in case a func is added between retrieving l and doing the if on it
		d.cond.L.Lock()

		// Get number of funcs in queue
		d.mq.Lock()
		l := len(d.queue)
		d.mq.Unlock()

		// No queued funcs
		if l == 0 {
			d.cond.Wait()
			d.cond.L.Unlock()
			continue
		}
		d.cond.L.Unlock()

		// Get first func
		d.mq.Lock()
		fn := d.queue[0]
		d.mq.Unlock()

		// Execute func
		fn()

		// Remove first func
		d.mq.Lock()
		d.queue = d.queue[1:]
		d.mq.Unlock()
	}
}
1113326
func (client *Client) Do(funcname string, data []byte,
	flag byte, h ResponseHandler) (handle string, err error) {
	var datatype uint32
	switch flag {
	case JobLow:
		datatype = dtSubmitJobLow
	case JobHigh:
		datatype = dtSubmitJobHigh
	default:
		datatype = dtSubmitJob
	}

	client.respHandler.Lock()
	defer client.respHandler.Unlock()
	handle, err = client.do(funcname, data, datatype)
	if err == nil && h != nil {
		client.respHandler.putNoLock(handle, h)
	}
	return
}
893873
func (r Request) Do() (Response, error) {
	client := &http.Client{}
	client.Timeout = r.Timeout
	res, err := client.Do(r.Req)
	return Response{res, r.URI}, err
}
1000198
func (c *ClusterClient) Do(args ...interface{}) *Cmd {
	cmd := NewCmd(args...)
	c.Process(cmd)
	return cmd
}
480777
func (s *ExistsService) Do(ctx context.Context) (bool, error) {
	// Check pre-conditions
	if err := s.Validate(); err != nil {
		return false, err
	}

	// Get URL for request
	path, params, err := s.buildURL()
	if err != nil {
		return false, err
	}

	// Get HTTP response
	res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
		Method:       "HEAD",
		Path:         path,
		Params:       params,
		IgnoreErrors: []int{404},
	})
	if err != nil {
		return false, err
	}

	// Return operation response
	switch res.StatusCode {
	case http.StatusOK:
		return true, nil
	case http.StatusNotFound:
		return false, nil
	default:
		return false, fmt.Errorf("elastic: got HTTP code %d when it should have been either 200 or 404", res.StatusCode)
	}
}
816304
func (c *Client) Do(req *http.Request) (*http.Response, error) {
	err := Sign(c.auth, req)
	if err != nil {
		return nil, err
	}

	return c.client.Do(req)
}
722888
func (q SearchQuery) Do(client *Client) (res SearchResult, err error) {
	fullUrl := fmt.Sprintf("search/%s", q)
	err = client.magicRequestDecoder("GET", fullUrl, nil, &res)
	return
}