-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feature/streaming report #389
Conversation
This function streams the wanted transactionIds from the db, then for each txId, the full transaction is fetch and returned to the user using backpressure. As a user, the rest endpoint response almost immediately with a 200 and then it start to download the transactions. This allows to easily download 1M tx without timeouts.
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.
Pretty cool how streaming is plugged in. Looks neat! 👍🏼
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.
Great job 👍 Most are nitpicking questions and comments.
app/src/main/scala/org/alephium/explorer/api/model/Transaction.scala
Outdated
Show resolved
Hide resolved
app/src/main/scala/org/alephium/explorer/persistence/queries/TransactionQueries.scala
Outdated
Show resolved
Hide resolved
app/src/main/scala/org/alephium/explorer/persistence/queries/TransactionQueries.scala
Outdated
Show resolved
Hide resolved
app/src/main/scala/org/alephium/explorer/service/TransactionService.scala
Outdated
Show resolved
Hide resolved
app/src/main/scala/org/alephium/explorer/service/TransactionService.scala
Show resolved
Hide resolved
app/src/test/scala/org/alephium/explorer/service/TransactionServiceSpec.scala
Outdated
Show resolved
Hide resolved
app/src/main/scala/org/alephium/explorer/api/model/Transaction.scala
Outdated
Show resolved
Hide resolved
Keeping the code behind it in services as it doesn't hurt.
When not providing a parent, we were always generated a genesis block, which isn't what we want for most of the tests.
Without batching we download between 500-900KB/s and with a batching at 100 it's around 1.5-2MB 🚀
With the two latest commits, we are now refusing to export addresses with more than 10K txs (within the time range). Currently the biggest exportable address has 8749 txs, and it takes 4s to dl the 6M csv file. |
Fighting a flaky test and after that we should be good. |
app/src/test/scala/org/alephium/explorer/api/model/ApiModelSpec.scala
Outdated
Show resolved
Hide resolved
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.
LGTM 🚀
Resolves: #374
We are still waiting
tapir
to release a new version, but my PR got merged few days ago .I still miss the tests, but I think it can be good to start reviewing it, as it's a new concept.
With streaming, when you call the endpoint, you get a response directly:
from the backend side we first fetch the txIds as a stream and as soon psql have the first txIds ready, it starts to push them down the flow, for each txId we fetch the tx detail and it goes down the stream to the http response. The user is dowloading each tx, like any download, we don't wait to have ALL tx to return them.
As it's reactive streams, the all things is using backpressure.
Using streams allows to be able to download for example the 1M+ txs from our biggest miner without issue.
cc/ @mvaivre for the two new endpoints:
max time interval is 365 days