-
Notifications
You must be signed in to change notification settings - Fork 233
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
Change session/cluster initialization to happen in the background CSHARP-916 #528
Open
joao-r-reis
wants to merge
31
commits into
4.x
Choose a base branch
from
CSHARP-916
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR doesn't unify Session and Cluster yet but a lot of these changes were made with the unification in mind which will come in a following PR. I'm opening this PR before fixing the test code in order to allow for an earlier review of the API changes/design @jorgebay |
* Remove IDisposable implementation * Move ControlConnection construction to Metadata * Add Metadata InitializeAsync and ShutdownAsync
- add IMetadata interface and change Metadata to be internal - add *Async methods to IMetadata - change internal references from Metadata to InternalMetadata - add *Snapshot methods to IMetadata
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently
cluster.Connect()
starts the initialization task of the control connection, then creates the session, then initializes the session.This PR changes this behavior so that
cluster.Connect()
creates the session object and returns it to the user immediately. The session initialization task is started in the background which will start the cluster initialization if it's not initialized yet.If a user attempts to do something with the
session
,cluster
orcluster.Metadata
that requires the initialization to be finished, the method will await/block until the initialization task is complete.I also implemented CSHARP-698 on this PR. It uses the reconnection policy to keep retrying the control connection initialization in the background. **After an initialization attempt fails, all method calls (
session.Execute
, etc.) will throw the original exception until a new attempt is started. When a new attempt is started, the methods will block again until the current attempt finishes.This PR also adds
Session.Connect()
for users that want to wait for the initialization to be finished.Several API changes are required in order for this to be a good experience for the user.
The
Cluster.Metadata
property no longer blocks. Also introduced aIMetadata
interface and aIMetadataSnapshotProvider
that declares someMetadata
methods which do not block.ILoadBalancingPolicy.Initialize
is called by the initialization method but aICluster
instance is passed to that method which means that if the user attempts to accessMetadata
it will deadlock because it requires the initialization task to be finished. This PR changes this method so that it receives aIMetadataSnapshotProvider
instance instead (which is inherited byIMetadata
). It also changes the method to support async (returnsTask
).A lot of methods from
ICluster
andISession
are moved toMetadata
. This simplifies the driver's API because these methods and properties were just wrappers of those inMetadata
so it makes more sense to be on theIMetadata
interface only.Also updated the upgrade guide so it's easier to get the overall picture of these API changes by reading the guide.