-
Notifications
You must be signed in to change notification settings - Fork 59
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
Make it possible for NewSession not to block #381
base: master
Are you sure you want to change the base?
Make it possible for NewSession not to block #381
Conversation
@dkropachev I've added this as a draft, I am not sure which way to go:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, let's make it optional, by default we will preserve old behavior
f366782
to
8d25897
Compare
For some use-cases it is helpful to be able to start the initialization of the Session, but not neccesarly wait for it to finish. To accomodate this need this commit adds new non blocking API. If the user tries to query Session that isn't initialized yet, the new ErrSessionNotReady will be returned.
8d25897
to
2d574ef
Compare
go func() { | ||
if initErr := s.init(); initErr != nil { | ||
s.sessionStateMu.Lock() | ||
s.initErr = fmt.Errorf("gocql: unable to create session: %v", initErr) | ||
s.sessionStateMu.Unlock() | ||
} | ||
|
||
s.readyCh <- s.initErr | ||
close(s.readyCh) | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please make this behavior optional, preserving old behavior by default.
Idea is the following:
Fixes: #234