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
e1b04ded
Commit
e1b04ded
authored
1 month ago
by
Dennis Collaris
Browse files
Options
Downloads
Patches
Plain Diff
fix: create new querypublisher for each message
parent
5dacd895
Branches
feat/reportOnNewData
No related tags found
1 merge request
!32
fix: create new querypublisher for each message
Pipeline
#146205
failed
1 month ago
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/readers/queryService.ts
+7
-8
7 additions, 8 deletions
src/readers/queryService.ts
src/utils/queryPublisher.ts
+7
-39
7 additions, 39 deletions
src/utils/queryPublisher.ts
with
14 additions
and
47 deletions
src/readers/queryService.ts
+
7
−
8
View file @
e1b04ded
...
...
@@ -78,8 +78,6 @@ 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
'
,
...
...
@@ -90,6 +88,13 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu
log
.
info
(
'
Connected to RabbitMQ ST!
'
);
await
queryServiceConsumer
.
startConsuming
<
QueryRequest
>
(
'
query-service
'
,
async
(
message
,
headers
)
=>
{
if
(
message
.
queryID
==
null
)
{
log
.
error
(
'
QueryID not set in message:
'
,
message
.
queryID
);
return
;
}
const
publisher
=
new
QueryPublisher
(
frontendPublisher
,
mlPublisher
,
headers
,
message
.
queryID
);
const
startTime
=
Date
.
now
();
const
ss
=
await
ums
.
getUserSaveState
(
headers
.
message
.
sessionData
.
userID
,
message
.
saveStateID
);
...
...
@@ -102,12 +107,6 @@ export const queryServiceReader = async (frontendPublisher: RabbitMqBroker, mlPu
log
.
debug
(
'
Received query request:
'
,
message
,
headers
,
ss
);
log
.
debug
(
'
Received routing key:
'
,
headers
.
routingKey
);
if
(
!
headers
.
callID
)
{
log
.
error
(
'
QueryID not set in headers:
'
,
headers
);
return
;
}
publisher
.
withHeaders
(
headers
).
withRoutingKey
(
headers
.
routingKey
).
withQueryID
(
headers
.
callID
);
publisher
.
publishStatusToFrontend
(
'
Received
'
);
if
(
ss
==
null
||
ss
.
dbConnections
==
null
||
ss
.
dbConnections
[
0
]
==
null
||
ss
.
dbConnections
.
length
===
0
)
{
...
...
This diff is collapsed.
Click to expand it.
src/utils/queryPublisher.ts
+
7
−
39
View file @
e1b04ded
...
...
@@ -6,35 +6,19 @@ import type { RabbitMqBroker } from 'ts-common/rabbitMq';
export
class
QueryPublisher
{
private
frontendPublisher
:
RabbitMqBroker
;
private
mlPublisher
:
RabbitMqBroker
;
private
routingKey
?
:
string
;
private
headers
?
:
BackendMessageHeader
;
private
queryID
?
:
string
;
private
routingKey
:
string
;
private
headers
:
BackendMessageHeader
;
private
queryID
:
number
;
constructor
(
frontendPublisher
:
RabbitMqBroker
,
mlPublisher
:
RabbitMqBroker
)
{
constructor
(
frontendPublisher
:
RabbitMqBroker
,
mlPublisher
:
RabbitMqBroker
,
headers
:
BackendMessageHeader
,
queryID
:
number
)
{
this
.
frontendPublisher
=
frontendPublisher
;
this
.
mlPublisher
=
mlPublisher
;
}
withHeaders
(
headers
?:
BackendMessageHeader
)
{
this
.
headers
=
headers
;
return
this
;
}
withRoutingKey
(
routingKey
?:
string
)
{
this
.
routingKey
=
routingKey
;
return
this
;
}
withQueryID
(
queryID
?:
string
)
{
this
.
routingKey
=
headers
.
routingKey
;
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
,
...
...
@@ -48,10 +32,6 @@ 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
,
...
...
@@ -65,17 +45,13 @@ 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
.
headers
.
call
ID
,
queryID
:
this
.
query
ID
,
},
status
:
'
success
'
,
},
...
...
@@ -85,10 +61,6 @@ 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
,
...
...
@@ -98,7 +70,7 @@ export class QueryPublisher {
type
:
'
nodelink
'
,
payload
:
result
,
},
queryID
:
this
.
headers
.
call
ID
,
queryID
:
this
.
query
ID
,
},
status
:
'
success
'
,
},
...
...
@@ -108,10 +80,6 @@ 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