Skip to content
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

Add reconnected handler to tendermint websocket client #1201

Closed
wants to merge 11 commits into from

Conversation

willclarktech
Copy link
Contributor

Closes #1200

I’m a little unclear on the acceptance criteria for this issue, so opening this draft PR now to get feedback. Is this basically what we need or is there something I’ve missed?

@willclarktech willclarktech force-pushed the 1200-client-reconnected-handler branch from 2f7b752 to 9352aa1 Compare August 15, 2019 10:02
Copy link
Contributor

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good direction. Let's keep the scope to Tendermint only and create a new ticket for Ethereum

const request = createJsonRpcRequest("subscribe", { query: query });
const producer = new RpcEventProducer(request, this.socket);
const stream = Stream.create(producer);
this.subscriptionStreams.set(query, stream);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets subscriptionStreams[subscriptionStreams] to a new reference. The old stream the caller got via const eventStream = this.client.listen(req); will not change, so the new events do not arrive.

Also this re-establishes subscribtions that nobody listens to anymore (where the original producer was stopped).

My feeling is that in public listen(request: JsonRpcRequest): Stream<SubscriptionEvent> { there needs to be a producer (maybe a wrapper around RpcEventProducer) which survives the reconnect and routes events from different sources.

@willclarktech willclarktech force-pushed the 1200-client-reconnected-handler branch from 9352aa1 to 9b03cad Compare August 15, 2019 11:41
Copy link
Contributor

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Any chance to test this? At least manually

@@ -131,6 +131,40 @@ class RpcEventProducer implements Producer<SubscriptionEvent> {
}
}

class ReconnectingRpcEventProducer implements Producer<SubscriptionEvent> {
public stopped: boolean = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can become private, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks, I originally had the check outside the class.

@willclarktech
Copy link
Contributor Author

@webmaster128 I’ll have a think about tests and then convert this to a non-draft PR.

@willclarktech willclarktech force-pushed the 1200-client-reconnected-handler branch 8 times, most recently from 86cff85 to a1c20f0 Compare August 21, 2019 17:21
@willclarktech willclarktech force-pushed the 1200-client-reconnected-handler branch from a1c20f0 to cf1fb7c Compare November 19, 2019 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use reconnectedHandler in Tendermint
2 participants