MCPcopy Index your code
hub / github.com/uber/aresdb / makeQuery

Function makeQuery

examples/examples.go:127–154  ·  view source on GitHub ↗
(queryName, queryType, queryPath string)

Source from the content-addressed store, hash-verified

125}
126
127func makeQuery(queryName, queryType, queryPath string) {
128 var err error
129 var file *os.File
130 file, err = os.Open(queryPath)
131 panicIfErr(err)
132
133 fmt.Printf("making query %s ... \n", queryName)
134 var resp *http.Response
135 if queryType == ".aql" {
136 resp, err = http.Post(fmt.Sprintf("http://%s:%d/query/aql", viper.GetString(hostKeyName), viper.GetInt(portKeyName)), "application/json", file)
137 } else if queryType == ".sql" {
138 resp, err = http.Post(fmt.Sprintf("http://%s:%d/query/sql", viper.GetString(hostKeyName), viper.GetInt(portKeyName)), "application/json", file)
139 } else {
140 err = fmt.Errorf("query file has to have .aql or .sql suffix")
141 }
142 panicIfErr(err)
143 if resp.StatusCode != http.StatusOK {
144 panic(fmt.Errorf("query failed with status code %d", resp.StatusCode))
145 }
146
147 result, err := ioutil.ReadAll(resp.Body)
148 panicIfErr(err)
149
150 prettJSON := &bytes.Buffer{}
151 panicIfErr(json.Indent(prettJSON, result, "", "\t"))
152
153 fmt.Println(prettJSON.String())
154}
155
156func createTable(tableName string, tableSchemaPath string) {
157 schemaFile, err := os.Open(tableSchemaPath)

Callers 1

queryDataSetFunction · 0.85

Calls 4

panicIfErrFunction · 0.85
OpenMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected