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 retry logic #17

Merged
merged 3 commits into from
Nov 15, 2019
Merged

Add retry logic #17

merged 3 commits into from
Nov 15, 2019

Conversation

grouma
Copy link
Member

@grouma grouma commented Nov 15, 2019

Unfortunately I don't have a good way to test the retry logic in a unit test. Open to suggestions. Went ahead and added the option to ensure we didn't regress on current tests.

Note we now close the eventSource on error as it continually attempts to reconnect. Somewhat related to dart-lang/webdev#818.

if (!(_errorTimer?.isActive ?? false)) {
// By default the SSE client uses keep-alive.
// Allow for a retry to connect before giving up.
_errorTimer = Timer(const Duration(seconds: 5), () {
Copy link
Member

Choose a reason for hiding this comment

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

Where did 5 seconds come from?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just a number that has worked well in practice for internal systems. Realistically the event source reconnect should be sub second. This gives plenty of overhead.

/// [serverUrl] is the URL under which the server is listening for
/// incoming bi-directional SSE connections.
SseClient(String serverUrl) {
SseClient(String serverUrl, {bool withRetry}) {
Copy link
Member

Choose a reason for hiding this comment

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

synced offline - since all of our known use cases will want to use retry I think we can roll to version 3.0.0 and make it non-optional. This package shouldn't have an overwhelming amount of churn to bump.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


- Add retry logic.

** Possible Breaking Change ** Error messages may now be delayed up to 5 seconds
Copy link
Member

Choose a reason for hiding this comment

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

Should we say "Error messages for disconnects"?

Copy link
Member Author

Choose a reason for hiding this comment

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

General error messages may be delayed as we have no way to make a distinction.

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.

2 participants