feat(session/database): add NewSessionServiceFromDB constructor#724
Open
nuthalapativarun wants to merge 4 commits intogoogle:mainfrom
Open
feat(session/database): add NewSessionServiceFromDB constructor#724nuthalapativarun wants to merge 4 commits intogoogle:mainfrom
nuthalapativarun wants to merge 4 commits intogoogle:mainfrom
Conversation
Adds NewSessionServiceFromDB(*gorm.DB) alongside the existing NewSessionService(dialector, opts...) so callers can pass a pre-opened *gorm.DB and share a single database connection across multiple services. The existing constructor is unchanged for backward compatibility. Fixes google#340
Author
|
Hi, just checking in on this one — happy to make any adjustments if something needs to change. Let me know if there's anything blocking review. Thanks! |
This file contains hidden or 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
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.
Link to Issue
Fixes #340
Description
Adds a
NewSessionServiceFromDB(*gorm.DB)constructor alongside the existingNewSessionService(dialector, opts...). This allows callers who already manage a database connection to share it across multiple services, rather than having the session service open its own connection.The existing
NewSessionServiceis unchanged for full backward compatibility, as suggested by the maintainer in the issue comments.Changes:
session/database/service.go: AddedNewSessionServiceFromDB(db *gorm.DB) (session.Service, error)which returns an error ifdbis nil.session/database/service_test.go: AddedTestNewSessionServiceFromDB(nil guard, valid db, shared connection verification) andTest_databaseServiceFromDBwhich runs the full service contract suite via the new constructor.Testing Plan
Test_databaseServiceFromDB) passes via the new constructorgo test ./session/database/...go build ./...