Skip to content
Snippets Groups Projects
Commit 286ca322 authored by thijsheijden's avatar thijsheijden
Browse files

Walking skeleton updates

parent 73b1d821
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"log"
"query-service/internal/aql"
"query-service/internal/errorhandler"
......@@ -37,8 +36,8 @@ func onMessageReceived(msg amqp.Delivery) {
// Retrieve JSON formatted string payload from msg
// Bypass MSQ
jsonQuery, _ := ioutil.ReadFile("./internal/data/jsonQuery.json")
aqlQuery, err := aql.ConvertJSONToAQL(&jsonQuery)
// jsonQuery, _ := ioutil.ReadFile("./internal/data/jsonQuery.json")
aqlQuery, err := aql.ConvertJSONToAQL(&msg.Body)
// Convert the json byte msg to an aql query string
//aqlQuery, err := aql.ConvertJSONToAQL(&msg.Body)
......@@ -63,6 +62,9 @@ func onMessageReceived(msg amqp.Delivery) {
// execute and retrieve result
// convert result to general (node-link (?)) format
result, err := request.SendAQLQuery(*aqlQuery)
if err != nil {
return // TODO: Send message in queue notifying of error
}
// publish converted result
headers := amqp.Table{}
......
......@@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: query-handler
image: datastropheregistry.azurecr.io/query-handler-service:latest
image: datastropheregistry.azurecr.io/query-service:latest
ports:
- containerPort: 3000
env:
......
......@@ -2,7 +2,7 @@ package request
import (
"context"
"fmt"
"log"
"encoding/json"
"io/ioutil"
......@@ -25,23 +25,24 @@ type GeneralFormat map[string]interface{}
func SendAQLQuery(AQLQuery string) (*[]byte, error) {
var queryResult []Document
conn, err := http.NewConnection(http.ConnectionConfig{
Endpoints: []string{"http://localhost:8529"},
Endpoints: []string{"http://arangodb.database.svc.cluster.local:8529"},
})
if err != nil {
fmt.Printf("Could not connect to the host") // Handle error
log.Println("could not connect to database") // Handle error
}
c, err := driver.NewClient(driver.ClientConfig{
Connection: conn,
Authentication: driver.BasicAuthentication("root", "GRYVKVN5M977QNdT"),
Authentication: driver.BasicAuthentication("root", "DikkeDraak"),
})
if err != nil {
fmt.Printf("Could not log in to the ArangoDB") // Handle error
log.Println("Could not log in to the ArangoDB") // Handle error
}
ctx := context.Background()
db, err := c.Database(ctx, "_system")
if err != nil {
// handle error
log.Println(err)
}
//fmt.Println(AQLQuery)
......@@ -56,7 +57,8 @@ func SendAQLQuery(AQLQuery string) (*[]byte, error) {
// `
cursor, err := db.Query(ctx, AQLQuery, nil)
if err != nil {
fmt.Printf("Invalid query") // handle error
log.Println("Invalid query") // handle error
return nil, err
}
defer cursor.Close()
for {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment