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
1c83db0d
Commit
1c83db0d
authored
4 years ago
by
sivan
Browse files
Options
Downloads
Patches
Plain Diff
also publish query translation result to the client
parent
fdf8958c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/usecases/consume/handlemessage.go
+23
-8
23 additions, 8 deletions
internal/usecases/consume/handlemessage.go
internal/usecases/convertquery/aqlStructs.go
+20
-20
20 additions, 20 deletions
internal/usecases/convertquery/aqlStructs.go
with
43 additions
and
28 deletions
internal/usecases/consume/handlemessage.go
+
23
−
8
View file @
1c83db0d
...
...
@@ -19,9 +19,21 @@ func (s *Service) HandleMessage(msg *brokeradapter.Message) {
// Convert the json byte msg to a query string
query
,
err
:=
s
.
queryConverter
.
ConvertQuery
(
&
msg
.
Body
)
if
err
!=
nil
{
errorhandler
.
LogError
(
err
,
"failed to parse incoming msg to query language"
)
// TODO:
don't panic on error,
send error message to client instead
errorhandler
.
LogError
(
err
,
"failed to parse incoming msg to query language"
)
// TODO: send error message to client instead
return
}
// Send the resulting query back to the client
msgmap
:=
make
(
map
[
string
]
interface
{})
msgmap
[
"type"
]
=
"query_translation_result"
msgmap
[
"pod"
]
=
podName
msgmap
[
"values"
]
=
*
query
msgbyte
,
err
:=
json
.
Marshal
(
msgmap
)
if
err
!=
nil
{
errorhandler
.
LogError
(
err
,
"Marshalling query_translation_result went wrong!"
)
// TODO: send error message to client instead
return
}
s
.
producer
.
PublishMessage
(
&
msgbyte
,
&
sessionID
)
// TODO: should this be a go routine?
fmt
.
Println
(
"Query: "
+
*
query
)
// Make request to database
...
...
@@ -35,12 +47,15 @@ func (s *Service) HandleMessage(msg *brokeradapter.Message) {
}
// Add type indicator to result from database
querymap
:=
make
(
map
[
string
]
interface
{})
querymap
[
"type"
]
=
"query_result"
querymap
[
"pod"
]
=
podName
querymap
[
"values"
]
=
*
result
querybyte
,
err
:=
json
.
Marshal
(
querymap
)
//fmt.Println(querymap)
resultMsgMap
:=
make
(
map
[
string
]
interface
{})
resultMsgMap
[
"type"
]
=
"query_result"
resultMsgMap
[
"pod"
]
=
podName
resultMsgMap
[
"values"
]
=
*
result
resultMsgByte
,
err
:=
json
.
Marshal
(
resultMsgMap
)
if
err
!=
nil
{
errorhandler
.
LogError
(
err
,
"Marshalling query_result went wrong!"
)
// TODO: send error message to client instead
return
}
s
.
producer
.
PublishMessage
(
&
queryb
yte
,
&
sessionID
)
s
.
producer
.
PublishMessage
(
&
resultMsgB
yte
,
&
sessionID
)
}
This diff is collapsed.
Click to expand it.
internal/usecases/convertquery/aqlStructs.go
+
20
−
20
View file @
1c83db0d
...
...
@@ -9,35 +9,28 @@ func NewService() *Service {
return
&
Service
{}
}
// Constraint datatypes
// text MatchTypes: exact/contains/startswith/endswith
// number MatchTypes: GT/LT/EQ
// bool MatchTypes: EQ/NEQ
// Ranges dus tussen 10 half 5 bijv.
// Struct used for JSON conversion of the incoming byte array
type
parsedJSON
struct
{
Return
returnStruct
//`json:"return"`
Entities
[]
entityStruct
//`json:"entities"`
Relations
[]
relationStruct
//`json:"relations"`
Return
returnStruct
Entities
[]
entityStruct
Relations
[]
relationStruct
}
// returnStruct holds the indices of the entities and relations that need to be returned
type
returnStruct
struct
{
Entities
[]
int
//`json:"entities"`
Relations
[]
int
//`json:"relation"`
Entities
[]
int
Relations
[]
int
}
// entityStruct encapsulates a single entity with its corresponding constraints
type
entityStruct
struct
{
Type
string
//`json:"type"`
Constraints
[]
constraintStruct
//`json:"constraints"`
Type
string
Constraints
[]
constraintStruct
}
// relationStruct encapsulates a single relation with its corresponding constraints
type
relationStruct
struct
{
Type
string
//`json:"type"`
Type
string
EntityFrom
int
EntityTo
int
Depth
searchDepthStruct
...
...
@@ -50,10 +43,17 @@ type searchDepthStruct struct {
Max
int
}
// constraintStruct holds the information of the constraint
/*
constraintStruct holds the information of the constraint
Constraint datatypes
text MatchTypes: exact/contains/startswith/endswith
number MatchTypes: GT/LT/EQ
bool MatchTypes: EQ/NEQ
*/
type
constraintStruct
struct
{
Attribute
string
//`json:"attribute"`
Value
string
//`json:"value"`
DataType
string
//`json:"dataType"`
MatchType
string
//`json:"matchType"`
Attribute
string
Value
string
DataType
string
MatchType
string
}
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