-
Notifications
You must be signed in to change notification settings - Fork 83
fix(webui): Improve Presto search metadata handling: #1280
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0eb5020
latest
49f879c
latest
6fb6b42
Merge branch 'main' into done
davemarco badc749
latest
d5c8705
Merge branch 'main' into done
65c7995
fix lint
40d0dd3
latest
db18948
latest
1f71f89
latest
63d133f
latest
716b60a
latest
ab8dcdb
latest
fbdfe5c
Merge branch 'main' into done
davemarco 828198d
Merge branch 'main' into done
hoophalab 59f410a
Merge branch 'main' into done
hoophalab 9eaec51
Merge branch 'main' into done
hoophalab 2cd72d6
Merge branch 'main' into done
davemarco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| import {Type} from "@sinclair/typebox"; | ||
|
|
||
|
|
||
| /** | ||
| * Unique ID for each active unique query. Multiple clients can subscribe to the same ID if the | ||
| * queries are identical. The ID is also used to represent the socket room, and MongoDB | ||
| * change stream. | ||
| */ | ||
| type QueryId = number; | ||
|
|
||
| /** | ||
| * Error response to event. | ||
| */ | ||
| interface Err { | ||
| error: string; | ||
| queryId?: QueryId; | ||
| } | ||
|
|
||
| /** | ||
| * Success response to event. | ||
| */ | ||
| interface Success<T> { | ||
| data: T; | ||
| } | ||
|
|
||
| /** | ||
| * Event response. | ||
| */ | ||
| type Response<T> = Err | Success<T>; | ||
|
|
||
|
|
||
| /** | ||
| * Events that the client can emit to the server. | ||
| */ | ||
| type ClientToServerEvents = { | ||
| "disconnect": () => void; | ||
| "collection::find::subscribe": ( | ||
| requestArgs: { | ||
| collectionName: string; | ||
| query: object; | ||
| options: object; | ||
| }, | ||
| callback: (res: Response<{queryId: QueryId; initialDocuments: object[]}>) => void) => void; | ||
| "collection::find::unsubscribe": ( | ||
| requestArgs: { | ||
| queryId: QueryId; | ||
| } | ||
| ) => Promise<void>; | ||
| }; | ||
|
|
||
| /** | ||
| * Events that the server can emit to the client. | ||
| */ | ||
| interface ServerToClientEvents { | ||
| // eslint-disable-next-line no-warning-comments | ||
| // TODO: Consider replacing this with `collection::find::update${number}`, which will | ||
| // limit callbacks being triggered in the client to their respective query IDs. | ||
| "collection::find::update": (respArgs: { | ||
| queryId: QueryId; | ||
| data: object[]; | ||
| }) => void; | ||
| } | ||
|
|
||
| /** | ||
| * Empty but required by Socket IO. | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-empty-object-type | ||
| interface InterServerEvents { | ||
| } | ||
|
|
||
| /** | ||
| * Collection associated with each socket connection. | ||
| */ | ||
| interface SocketData { | ||
| collectionName?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Enum of search-related signals. | ||
| * | ||
| * This includes request and response signals for various search operations and their respective | ||
| * states. | ||
| */ | ||
| enum SEARCH_SIGNAL { | ||
| NONE = "none", | ||
|
|
||
| REQ_CANCELLING = "req-cancelling", | ||
| REQ_CLEARING = "req-clearing", | ||
| REQ_QUERYING = "req-querying", | ||
|
|
||
| RESP_DONE = "resp-done", | ||
| RESP_QUERYING = "resp-querying", | ||
| } | ||
|
|
||
| /** | ||
| * Presto search-related signals. | ||
| */ | ||
| enum PRESTO_SEARCH_SIGNAL { | ||
| QUERYING = "QUERYING", | ||
| FAILED = "FAILED", | ||
| DONE = "DONE" | ||
| } | ||
|
|
||
| /** | ||
| * CLP query engines. | ||
| */ | ||
| enum CLP_QUERY_ENGINES { | ||
| CLP = "clp", | ||
| CLP_S = "clp-s", | ||
| PRESTO = "presto", | ||
| } | ||
|
|
||
| /** | ||
| * MongoDB document for search results metadata. `numTotalResults` is optional | ||
| * since it is only set when the search job is completed. | ||
| */ | ||
| interface SearchResultsMetadataDocument { | ||
| _id: string; | ||
|
|
||
| // eslint-disable-next-line no-warning-comments | ||
| // TODO: Replace with Nullable<string> when the `@common` directory refactoring is completed. | ||
| errorMsg: string | null; | ||
| errorName: string | null; | ||
| lastSignal: SEARCH_SIGNAL | PRESTO_SEARCH_SIGNAL; | ||
| numTotalResults?: number; | ||
| queryEngine: CLP_QUERY_ENGINES; | ||
| } | ||
|
|
||
| /** | ||
| * Presto row wrapped in a `row` property to prevent conflicts with MongoDB's `_id` field. | ||
| */ | ||
| interface PrestoRowObject { | ||
| row: Record<string, unknown>; | ||
| } | ||
|
|
||
| /** | ||
| * Presto search result in MongoDB. | ||
| */ | ||
| interface PrestoSearchResult extends PrestoRowObject { | ||
| _id: string; | ||
| } | ||
|
|
||
| /** | ||
| * Test TypeBox schema for testing dependency. | ||
| */ | ||
| // eslint-disable-next-line no-warning-comments | ||
| // TODO: Will be removed once shared server/client route types are migrated into common. | ||
| const TestTypeBoxSchema = Type.Object({ | ||
| type: Type.String(), | ||
| }); | ||
|
|
||
| export { | ||
| CLP_QUERY_ENGINES, | ||
| PRESTO_SEARCH_SIGNAL, | ||
| SEARCH_SIGNAL, | ||
| TestTypeBoxSchema, | ||
| }; | ||
| export type { | ||
| ClientToServerEvents, | ||
| Err, | ||
| InterServerEvents, | ||
| PrestoRowObject, | ||
| PrestoSearchResult, | ||
| QueryId, | ||
| Response, | ||
| SearchResultsMetadataDocument, | ||
| ServerToClientEvents, | ||
| SocketData, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.