-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review debug reaction #155
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 5f3d793.
reactions/platform/debug-reaction/debug-reaction.Server/Properties/launchSettings.json
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.Server/Properties/launchSettings.json
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.Server/Properties/launchSettings.json
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.Server/Properties/launchSettings.json
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.Server/Properties/launchSettings.json
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.Server/Services/ResultViewClient.cs
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.client/src/App.jsx
Dismissed
Show dismissed
Hide dismissed
reactions/platform/debug-reaction/debug-reaction.client/src/main.jsx
Dismissed
Show dismissed
Hide dismissed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/EventStream.jsx
Dismissed
Show dismissed
Hide dismissed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Dismissed
Show dismissed
Hide dismissed
|
||
[ApiController] | ||
[Route("query")] | ||
public class QueryController : ControllerBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should follow RESTful conventions. Having a queries
and a query
route is confusing.
eg.
GET / PUT / DELETE /query/<id>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Planning to implement the followings:
queries
- used for retrieving a list of queries that the reaction is subscribed to
queries/{queryId}
- for retrieving the current result set of a query. This is used when the page loads up and when the user clicks the
reinitialize query cache
button
queries/{queryId}/debug-information
- for debug info like query host, status and etc.
reactions/platform/debug-reaction/debug-reaction.Server/Models/QueryResult.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Services/IQueryDebugService.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Services/QueryDebugService.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Controllers/QueryController.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Services/ResultViewClient.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Program.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.client/src/pages/QueryPage.jsx
Fixed
Show fixed
Hide fixed
reactions/platform/debug-reaction/debug-reaction.Server/Program.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Program.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Program.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Program.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Program.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Services/QueryDebugService.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
|
||
private async Task<QueryResult> InitResult(string queryId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this method is invoked for the same query twice, before the first one completes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I did some searches online and it seems like one promising approach is to store/cache Task using a ConcurrentDicitionary
. That way concurrent invocation to this method will share the same result. Any thoughts on this approach @danielgerlag ?
reactions/platform/debug-reaction/debug-reaction.Server/Services/QueryDebugService.cs
Outdated
Show resolved
Hide resolved
reactions/platform/debug-reaction/debug-reaction.Server/Services/QueryDebugService.cs
Outdated
Show resolved
Hide resolved
|
||
const fetchStream = async () => { | ||
try { | ||
const url = "http://localhost:5195/stream"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the front end and back end run in separate pods, how would localhost
reach the backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we are still relying on port-forwarding both the frontend and the backend pods. I haven't looked into intra-cluster communication using k8s services yet, but I'll spend some time during this iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could serve the front-end app content from the /
route of the backend, and it could connect to the /api/*
routes for the same address. That way, we don't need two containers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me give it a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was able to get it working! Just need to clean up a few things
|
||
|
||
var port = Environment.GetEnvironmentVariable("PORT") ?? "8080"; | ||
server.Urls.Add($"http://0.0.0.0:{port}"); |
Check warning
Code scanning / devskim
An HTTP-based URL without TLS was detected. Warning
} | ||
} | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", |
Check warning
Code scanning / devskim
An HTTP-based URL without TLS was detected. Warning
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:30442", |
Check notice
Code scanning / devskim
Accessing localhost could indicate debug code, or could hinder scaling. Note
reactions/platform/debug-reaction/Properties/launchSettings.json
Dismissed
Show dismissed
Hide dismissed
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "https://localhost:7230;http://localhost:5195", |
Check notice
Code scanning / devskim
Accessing localhost could indicate debug code, or could hinder scaling. Note
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "https://localhost:7230;http://localhost:5195", |
Check notice
Code scanning / devskim
Accessing localhost could indicate debug code, or could hinder scaling. Note
…/drasi-platform into review-debug-reaction * 'review-debug-reaction' of https://github.com/ruokun-niu/drasi-platform: Transition to Native Multi-Platform Builds for Docker Images (drasi-project#161) Bump jinja2 from 3.1.4 to 3.1.5 in /reactions/sdk/python (drasi-project#135) Bump vite in /reactions/signalr/signalr-reaction/clients/vue (drasi-project#142) Bump nanoid in /reactions/signalr/signalr-reaction/clients/react/example (drasi-project#131) Bump openssl from 0.10.66 to 0.10.71 in /query-container (drasi-project#160) Bump golang.org/x/crypto from 0.26.0 to 0.31.0 in /cli (drasi-project#132) Bump nanoid in /reactions/signalr/signalr-reaction/clients/vue/example (drasi-project#130) Bump openssl from 0.10.68 to 0.10.71 in /sources/sdk/rust/example/proxy (drasi-project#158) Bump io.undertow:undertow-core from 2.3.15.Final to 2.3.17.Final in /sources/sdk/java (drasi-project#127) Bump esbuild from 0.16.17 to 0.25.0 in /dev-tools/vscode/drasi (drasi-project#151) Bump openssl from 0.10.66 to 0.10.70 in /control-planes/mgmt_api (drasi-project#148) Remove Fixed Dapr Version Constraint (drasi-project#147) Gremlin Reaction hotfix (drasi-project#149)
|
||
private readonly ILogger<QueryDebugService> _logger; | ||
|
||
private readonly ConcurrentDictionary<string, Task<QueryResult>> _activeQueries = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are moving the query result state to the client, why do we need it keep it here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented this dictionary for storing the task of initilializing the query results. This dictionary is only used in the InitResult
method, which uses the ResultViewClient to get the initial result for a query.
Let us say that we have a query called query1
that is trying to initialize. In the first invocation, the method will check the dictionary. query1
is not present in the dict, it will execute lambda function and store the Task in the dictionary. If there is a second invocation (before the first one completes), it will wait and return the same Task that is in progress.
The downside is that data might have changed in between the two invocations, but the second invocation will not reflect the new changes. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we did not store the result set on this tier at all, the front end could invoke a route that proxies a request for the initial query result through to the view service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Let me update this
|
||
private readonly ConcurrentDictionary<string, Task<QueryResult>> _activeQueries = new(); | ||
|
||
private readonly LinkedList<JsonElement> _rawEvents = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep this data here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
Description
Type of change
Fixes: #issue_number