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

Add support for multiple drivers in same session #7

Merged
merged 1 commit into from Feb 15, 2021
Merged

Conversation

andy-kimball
Copy link
Contributor

@andy-kimball andy-kimball commented Feb 13, 2021

Allow connections to be made using different SQL drivers in the same copyist
session. Records generated by different drivers are stored the same way as
if there was just a single driver - in the same recording file.

The main thing preventing this from working before was that the proxyDriver
was the top-level object which stored session state. Now all session state
is broken out into a new session object which can manage multiple drivers.

Note also that this change means that Register can no longer take a resetDB
argument, since there should not be a different reset function for each
driver. A new SetSessionInit function can now be used to set the callback
function that is invoked each time a new copyist session is started.

This last change does break API backwards compatibility. But since I don't
think copyist is widely used, I'm not going to add "/v2" to the import
path, even though that's not allowed according to the SemVer spec.


This change is Reviewable

Copy link
Contributor

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm:

This was mainly code movement into the session struct, right?

Reviewable status: 0 of 24 files reviewed, 1 unresolved discussion (waiting on @andy-kimball)


session.go, line 60 at r1 (raw file):

// or write a new recording of the given name in a file with the given path
// name.
func NewSession(pathName, recordingName string) *session {

Does this need to be exported? I'm pretty sure no given that session itself isn't exported. One of the linters in CRDB actually complains about returning an unexported type from an exported function due to the inability to actually use the type for anything useful.

Allow connections to be made using different SQL drivers in the same copyist
session. Records generated by different drivers are stored the same way as
if there was just a single driver - in the same recording file.

The main thing preventing this from working before was that the proxyDriver
was the top-level object which stored session state. Now all session state
is broken out into a new session object which can manage multiple drivers.

Note also that this change means that Register can no longer take a resetDB
argument, since there should not be a different reset function for each
driver. A new SetSessionInit function can now be used to set the callback
function that is invoked each time a new copyist session is started.

This last change does break API backwards compatibility. But since I don't
think copyist is widely used, I'm not going to add "/v2" to the import
path, even though that's not allowed according to the SemVer spec.
Copy link
Contributor Author

@andy-kimball andy-kimball left a comment

Choose a reason for hiding this comment

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

Yes, refactoring so that we can have 1:MANY session:drivers instead of 1:1.

Reviewable status: 0 of 24 files reviewed, 1 unresolved discussion (waiting on @petermattis)


session.go, line 60 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Does this need to be exported? I'm pretty sure no given that session itself isn't exported. One of the linters in CRDB actually complains about returning an unexported type from an exported function due to the inability to actually use the type for anything useful.

Was mistake on my part. Fixed.

@andy-kimball andy-kimball merged commit 1a2ce6b into master Feb 15, 2021
@andy-kimball andy-kimball deleted the multi branch February 15, 2021 23:17
andy-kimball added a commit that referenced this pull request Feb 15, 2021
Allow connections to be made using different SQL drivers in the same copyist
session. Records generated by different drivers are stored the same way as
if there was just a single driver - in the same recording file.

The main thing preventing this from working before was that the proxyDriver
was the top-level object which stored session state. Now all session state
is broken out into a new session object which can manage multiple drivers.

Note also that this change means that Register can no longer take a resetDB
argument, since there should not be a different reset function for each
driver. A new SetSessionInit function can now be used to set the callback
function that is invoked each time a new copyist session is started.

This last change does break API backwards compatibility. But since I don't
think copyist is widely used, I'm not going to add "/v2" to the import
path, even though that's not allowed according to the SemVer spec.
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