-
Notifications
You must be signed in to change notification settings - Fork 3
Server Sent Events on API #706
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
base: develop
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
# Conflicts: # packages/api/src/dao/TransactionsDAO.js
| } | ||
|
|
||
| subscribeBlockWithTransactions = async (request, response) => { | ||
| await checkSSEConditions(this.redis, this.blocksDAO) |
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 redis is available, then we can use it, I think we can do it by conditionally passing the redis in the constructor, and handle optionality on creation level
| response.raw.writeHead(200, SSE_HEAD) | ||
|
|
||
| const redis = await this.redis.duplicate() | ||
| await redis.connect() |
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 think that should handled in the separate RedisClient class
| if last_block_height > current_block_height + 10 { | ||
| self.processor.set_indexing_flag(true).await; |
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.
Use catchingUp from tenderdash RPC
| await this.redis.subscribeMessages(callback) | ||
|
|
||
| // initialize sse | ||
| response.sse({ data: JSON.stringify({ status: 'ok' }) }) |
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's return current block in as first message
dependent #716
Issue
We need to implement endpoints with SSE which allows to get in real time updates of indexer
Things done
keep-aliveconnectionImplemented events based blocks pool, which allows blocks to be sent in the correct order, otherwise the sending order will be disrupted due to different waiting times for several blocks with consecutive transactions or any other delaysImplementedgetBlockWithTransactionforBlocksDAORedisConnection, which allows to interact with redis via only 2 connections