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

Resolve pubsub future only when nothing can happen anymore #72

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dippi
Copy link

@dippi dippi commented Jul 4, 2021

With these changes PubsubConnectionInner should complete only if every PubsubConnection have been dropped.

It should be enough to guarantee that:

  • there are no open subscriptions (PubsubStream keeps a reference to PubsubConnection and unsubscribes when dropped)
  • there's no one waiting on pending subscriptions (the promise keeps a reference to PubsubConnection)
  • no one will subscribe again (you need a PubsubConnection to do that)

Fixes #50

.unwrap();
}
return Err(error::Error::Connection(ConnectionReason::NotConnected));
// This can only happen if the connection is closed server-side
Copy link
Author

@dippi dippi Jul 4, 2021

Choose a reason for hiding this comment

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

Here I removed the handling of the special case, because I couldn't think of a reason to keep it. Am I missing anything?

}

#[tokio::test]
async fn test_connection_is_closed_after_channel_is_dropped() {
Copy link
Author

Choose a reason for hiding this comment

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

I had to do this test outside the test module, to have access to the private types. Is there a better way?

@mcatanzariti
Copy link

Any chance this PR could be accepted ?

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.

Internal("Subscription failed, try again later...") on pubsub
2 participants