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

feat: Improve timeout handling in OutboundMessageListener #201

Merged
merged 10 commits into from
Jul 15, 2022

Conversation

murali-shris
Copy link
Member

@murali-shris murali-shris commented Jul 13, 2022

- What I did

  • Replaced retries and absolute wait time with transient time out
    - How I did it
  • introduced option param transientWaitTimeMillis in read method of outbound_message_listener.dart. Added _lastReceivedTime
  • when partial response is received from server and full response is not received within transientWaitTimeMillis , throw timeout exception
  • when data arrives set _lastReceivedTime
  • even after waiting for transientWaitTimeMillis, if full message is not received until maxWaitMillis, close connection and throw timeoutexception
    - How to verify it
    Run the unit test group - A group of tests to verify AtTimeOutException in outbound_message_listener.dart

Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

I’m not sure about the logic.

messageHandler is the best place to keep track of when data was last received, with read() setting an initial value of “now” for that variable. When data is received, update that variable

Read can then do two checks
(1) has total time exceeded max time
(2) has difference between “now” and dataLastReceived exceeded transientWaitMillis

@murali-shris murali-shris requested a review from gkc July 14, 2022 07:01
@murali-shris murali-shris marked this pull request as ready for review July 14, 2022 07:01
@murali-shris
Copy link
Member Author

I’m not sure about the logic.

messageHandler is the best place to keep track of when data was last received, with read() setting an initial value of “now” for that variable. When data is received, update that variable

Read can then do two checks (1) has total time exceeded max time (2) has difference between “now” and dataLastReceived exceeded transientWaitMillis

chnages are done

@murali-shris
Copy link
Member Author

@gkc please review my unit tests whether they cover all the scenarios and whether the tests make sense

@@ -177,4 +177,65 @@ void main() {
expect(response, 'stream:@bob:phone@alice');
});
});

group('A group of tests to verify AtTimeOutException', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good work! Main thing missing now is tests where we start a read, then we send data in chunks to the messageHandler but with delays ('await Future.delayed(Duration(xxx))`) of various lengths in between, and check both positive and negative scenarios over longer durations

Copy link
Member Author

Choose a reason for hiding this comment

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

added two tests

  1. A test to verify full response received - delay between messages from server
  2. A test to verify timeout - delay between messages from server
    Please check whether this is inline with what you expected.
    Will try to add more tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good!

@murali-shris
Copy link
Member Author

murali-shris commented Jul 15, 2022

draft PR to check at client tests with current changes in at_lookup
atsign-foundation/at_client_sdk#605

@murali-shris murali-shris requested a review from gkc July 15, 2022 07:07
Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

LGTM

I see all tests passing in at_client_sdk using this branch (atsign-foundation/at_client_sdk#605) so I think we're good to go

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.

None yet

2 participants