Skip to content

Add isOpen and closed #222

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

Merged
merged 2 commits into from
Nov 1, 2023
Merged

Add isOpen and closed #222

merged 2 commits into from
Nov 1, 2023

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Nov 1, 2023

The two getters allow checking the current state of a postgres session, as well as getting notified when it closes. This combination mirrors the API of asynchronous primitives (like StreamConsumer or StreamChannel).

I think this should close the remaining concern of #119, but as @osaxma suggested we might want to wait until we have a clearer understanding of the requirements for this.

@codecov-commenter
Copy link

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (1cf35f1) 86.75% compared to head (65e3997) 86.76%.
Report is 4 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #222      +/-   ##
==========================================
+ Coverage   86.75%   86.76%   +0.01%     
==========================================
  Files          32       32              
  Lines        2779     2804      +25     
==========================================
+ Hits         2411     2433      +22     
- Misses        368      371       +3     
Files Coverage Δ
lib/postgres.dart 57.14% <ø> (ø)
lib/src/auth/clear_text_authenticator.dart 100.00% <ø> (ø)
lib/src/auth/md5_authenticator.dart 0.00% <ø> (ø)
lib/src/auth/sasl_authenticator.dart 88.57% <ø> (ø)
lib/src/exceptions.dart 91.48% <ø> (ø)
lib/src/message_window.dart 94.54% <ø> (ø)
lib/src/messages/client_messages.dart 83.21% <ø> (ø)
lib/src/messages/logical_replication_messages.dart 69.59% <ø> (ø)
lib/src/messages/server_messages.dart 80.48% <ø> (ø)
lib/src/messages/shared_messages.dart 30.00% <ø> (ø)
... and 5 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@isoos
Copy link
Owner

isoos commented Nov 1, 2023

I like this. The only thing I would consider is to use isClosed (vs isOpen) alongside with closed and maybe eventually close() (if we ever have non-callback based Sessions...). But this is good as-is, merging for now, and if you feel different about the open/close part, we can change it.

@isoos isoos merged commit efa2aa7 into isoos:master Nov 1, 2023
@simolus3 simolus3 deleted the connection-state branch November 2, 2023 09:39
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.

3 participants