Update firehose client to accept start param and remove keep-alive#1
Open
Harsh24893 wants to merge 1 commit intoreddit:mainfrom
Open
Update firehose client to accept start param and remove keep-alive#1Harsh24893 wants to merge 1 commit intoreddit:mainfrom
Harsh24893 wants to merge 1 commit intoreddit:mainfrom
Conversation
adamthesax
requested changes
Oct 19, 2023
adamthesax
left a comment
There was a problem hiding this comment.
A few changes. Also can you verify we still need this:
// keeps node process alive to restart the stream // keeps node process alive to restart the stream
setInterval(() => {}, 1 << 30); setInterval(() => {}, 1 << 30);
Not entirely sure if it's needed
|
|
||
| program.option('--keep-alive'); | ||
|
|
||
| program.parse(); |
There was a problem hiding this comment.
suggestion: Let's lean into command line arguments and away form environment variables
It makes it easier to understand what the program needs (--help) versus reading docs/docs
| }, | ||
| params: { | ||
| keep_alive: program.opts().keepAlive, | ||
| start: process.env.START, |
There was a problem hiding this comment.
issue: This will always reconnect to whatever start value is passed in leading to duplicate messages. What we want to do is keep start up-to-date with the last Id seen.
Something like:
let start = program.opts.start
async function listen() {
const stream = await initStream();
stream
.on('data', (chunk) => {
const data = JSON.parse(chunk.toString());
start = data.id
})
}
async function initStream() {
...blahblahblah...
params: { start }
}[
|
One other thought is we should move away from assuming a chunk is a message and use a line reader for this. See It's more accurate/robust and better represents our protocol. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
💸 TL;DR
🧪 Testing Steps / Validation
Tested by
npm startand fetching in a token id and subscription id