queryWithTsForResp query the dgraph and returns it's http response and result.
(inp queryInp)
| 173 | |
| 174 | // queryWithTsForResp query the dgraph and returns it's http response and result. |
| 175 | func queryWithTsForResp(inp queryInp) (string, *tsInfo, *http.Response, error) { |
| 176 | params := make([]string, 0, 3) |
| 177 | if inp.debug != "" { |
| 178 | params = append(params, "debug="+inp.debug) |
| 179 | } |
| 180 | if inp.ts != 0 { |
| 181 | params = append(params, fmt.Sprintf("startTs=%v", strconv.FormatUint(inp.ts, 10))) |
| 182 | params = append(params, fmt.Sprintf("hash=%s", inp.hash)) |
| 183 | } |
| 184 | if inp.respFmt != "" { |
| 185 | params = append(params, fmt.Sprintf("respFormat=%s", inp.respFmt)) |
| 186 | } |
| 187 | url := addr + "/query?" + strings.Join(params, "&") |
| 188 | |
| 189 | _, body, resp, err := runWithRetriesForResp("POST", inp.typ, url, inp.body) |
| 190 | if err != nil { |
| 191 | return "", nil, resp, err |
| 192 | } |
| 193 | |
| 194 | var r res |
| 195 | if err := json.Unmarshal(body, &r); err != nil { |
| 196 | return "", nil, resp, err |
| 197 | } |
| 198 | startTs := r.Extensions.Txn.StartTs |
| 199 | hash := r.Extensions.Txn.Hash |
| 200 | |
| 201 | // Remove the extensions |
| 202 | r2 := res{Data: r.Data} |
| 203 | output, err := json.Marshal(r2) |
| 204 | return string(output), &tsInfo{ts: startTs, hash: hash}, resp, err |
| 205 | } |
| 206 | |
| 207 | type mutationResponse struct { |
| 208 | keys []string |
no test coverage detected