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
8891e85d
Commit
8891e85d
authored
2 weeks ago
by
Marcos Pieras
Browse files
Options
Downloads
Patches
Plain Diff
feat: adds updates
parent
044faf06
No related branches found
Branches containing commit
No related tags found
5 merge requests
!42
test: adds return message to handle e2e tests
,
!40
test: adds test on populate template
,
!37
chore: adds precommit and commitlint
,
!35
test: adds tests on statcheck and diffcheck
,
!34
test: adds tests for query service
Pipeline
#146814
passed
2 weeks ago
Stage: tag-release
Stage: get-release-tag
Stage: container-image
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bun.lockb
+0
-0
0 additions, 0 deletions
bun.lockb
src/readers/queryService.ts
+2
-0
2 additions, 0 deletions
src/readers/queryService.ts
src/utils/queryPublisher.ts
+39
-7
39 additions, 7 deletions
src/utils/queryPublisher.ts
with
41 additions
and
7 deletions
bun.lockb
+
0
−
0
View file @
8891e85d
No preview for this file type
This diff is collapsed.
Click to expand it.
src/readers/queryService.ts
+
2
−
0
View file @
8891e85d
...
...
@@ -87,6 +87,8 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu
}
log
.
info
(
'
Starting query reader for
'
,
type
);
const
publisher
=
new
QueryPublisher
(
frontendPublisher
,
mlPublisher
);
const
queryServiceConsumer
=
await
new
RabbitMqBroker
(
rabbitMq
,
'
requests-exchange
'
,
...
...
This diff is collapsed.
Click to expand it.
src/utils/queryPublisher.ts
+
39
−
7
View file @
8891e85d
...
...
@@ -6,19 +6,35 @@ import type { RabbitMqBroker } from 'ts-common/rabbitMq';
export
class
QueryPublisher
{
private
frontendPublisher
:
RabbitMqBroker
;
private
mlPublisher
:
RabbitMqBroker
;
private
routingKey
:
string
;
private
headers
:
BackendMessageHeader
;
private
queryID
:
number
;
private
routingKey
?
:
string
;
private
headers
?
:
BackendMessageHeader
;
private
queryID
?
:
string
;
constructor
(
frontendPublisher
:
RabbitMqBroker
,
mlPublisher
:
RabbitMqBroker
,
headers
:
BackendMessageHeader
,
queryID
:
number
)
{
constructor
(
frontendPublisher
:
RabbitMqBroker
,
mlPublisher
:
RabbitMqBroker
)
{
this
.
frontendPublisher
=
frontendPublisher
;
this
.
mlPublisher
=
mlPublisher
;
}
withHeaders
(
headers
?:
BackendMessageHeader
)
{
this
.
headers
=
headers
;
this
.
routingKey
=
headers
.
routingKey
;
return
this
;
}
withRoutingKey
(
routingKey
?:
string
)
{
this
.
routingKey
=
routingKey
;
return
this
;
}
withQueryID
(
queryID
?:
string
)
{
this
.
queryID
=
queryID
;
return
this
;
}
publishStatusToFrontend
(
status
:
string
)
{
if
(
!
this
.
headers
||
!
this
.
routingKey
||
!
this
.
queryID
)
{
throw
new
Error
(
'
Headers or RoutingKey or queryID not set
'
);
}
this
.
frontendPublisher
.
publishMessageToFrontend
(
{
type
:
wsReturnKey
.
queryStatusUpdate
,
...
...
@@ -32,6 +48,10 @@ export class QueryPublisher {
}
publishErrorToFrontend
(
reason
:
string
)
{
if
(
!
this
.
headers
||
!
this
.
routingKey
||
!
this
.
queryID
)
{
throw
new
Error
(
'
Headers or RoutingKey or queryID not set
'
);
}
this
.
frontendPublisher
.
publishMessageToFrontend
(
{
type
:
wsReturnKey
.
queryStatusError
,
...
...
@@ -45,13 +65,17 @@ export class QueryPublisher {
}
publishTranslationResultToFrontend
(
query
:
string
)
{
if
(
!
this
.
headers
||
!
this
.
routingKey
||
!
this
.
queryID
)
{
throw
new
Error
(
'
Headers or RoutingKey or queryID not set
'
);
}
this
.
frontendPublisher
.
publishMessageToFrontend
(
{
type
:
wsReturnKey
.
queryStatusTranslationResult
,
callID
:
this
.
headers
.
callID
,
value
:
{
result
:
query
,
queryID
:
this
.
query
ID
,
queryID
:
this
.
headers
.
call
ID
,
},
status
:
'
success
'
,
},
...
...
@@ -61,6 +85,10 @@ export class QueryPublisher {
}
publishResultToFrontend
(
result
:
GraphQueryResultMetaFromBackend
)
{
if
(
!
this
.
headers
||
!
this
.
routingKey
||
!
this
.
queryID
)
{
throw
new
Error
(
'
Headers or RoutingKey or queryID not set
'
);
}
this
.
frontendPublisher
.
publishMessageToFrontend
(
{
type
:
wsReturnKey
.
queryStatusResult
,
...
...
@@ -70,7 +98,7 @@ export class QueryPublisher {
type
:
'
nodelink
'
,
payload
:
result
,
},
queryID
:
this
.
query
ID
,
queryID
:
this
.
headers
.
call
ID
,
},
status
:
'
success
'
,
},
...
...
@@ -80,6 +108,10 @@ export class QueryPublisher {
}
publishMachineLearningRequest
(
result
:
GraphQueryResultFromBackend
,
mlAttributes
:
MachineLearning
,
headers
:
BackendMessageHeader
)
{
if
(
!
this
.
headers
||
!
this
.
routingKey
)
{
throw
new
Error
(
'
Headers or RoutingKey or queryID not set
'
);
}
// FIXME: Change ML to use the same message format that the frontend uses
const
toMlResult
=
{
nodes
:
result
.
nodes
.
map
(
node
=>
({
...
node
,
id
:
node
.
_id
})),
...
...
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