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.
This adds a
Client::subscribe_progress
method that allows subscribing to query progress events sent by the server. This is very useful to track the progress of larger queries.The implementation uses a
tokio::sync::broadcast
, which only keeps the most recent events and sends them to subscribers. It is pretty short given that the blocks were already parsed.This was briefly mentioned in #10 (comment)
Tests
This was tested through the "basic" example, adapted to display progress, and against a real database.
Matching progress against queries
Note that the
Client::query*
interfaces currently do not provide the ID of the query, so it is not yet possible to match progress events against exact queries. Nevertheless, the commit already populates the ID of queries, and returns it as part of the progress stream.Later, The
Client::query*
should likely be adapted to return the query ID in addition to the Block stream. Then either:subscribe_progress
interfaceBlock
orProgress
.An alternative is to add a method to
Client
to return the ID of the query currently executing; this would be almost trivial.