Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Microservices
query-service
Commits
286ca322
Commit
286ca322
authored
3 years ago
by
thijsheijden
Browse files
Options
Downloads
Patches
Plain Diff
Walking skeleton updates
parent
73b1d821
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/query-service/main.go
+5
-3
5 additions, 3 deletions
cmd/query-service/main.go
deployments/deployment.yml
+1
-1
1 addition, 1 deletion
deployments/deployment.yml
internal/request/request.go
+8
-6
8 additions, 6 deletions
internal/request/request.go
with
14 additions
and
10 deletions
cmd/query-service/main.go
+
5
−
3
View file @
286ca322
...
...
@@ -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
(
&
jsonQuer
y
)
//
jsonQuery, _ := ioutil.ReadFile("./internal/data/jsonQuery.json")
aqlQuery
,
err
:=
aql
.
ConvertJSONToAQL
(
&
msg
.
Bod
y
)
// 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
{}
...
...
This diff is collapsed.
Click to expand it.
deployments/deployment.yml
+
1
−
1
View file @
286ca322
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
internal/request/request.go
+
8
−
6
View file @
286ca322
...
...
@@ -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://local
host
:8529"
},
Endpoints
:
[]
string
{
"http://
arangodb.database.svc.cluster.
local:8529"
},
})
if
err
!=
nil
{
fmt
.
Print
f
(
"
C
ould not connect to
the host
"
)
// Handle error
log
.
Print
ln
(
"
c
ould 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
.
Print
f
(
"Could not log in to the ArangoDB"
)
// Handle error
log
.
Print
ln
(
"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
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment