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

GODRIVER-2800 Convert Session Interface to a Struct #1592

Merged
merged 11 commits into from Apr 30, 2024

Conversation

prestonvasquez
Copy link
Collaborator

GODRIVER-2800

Summary

Replace the session interface with a struct.

Background & Motivation

Currently there is only one implementation of the Session interface in the Go Driver, the sessionImpl struct. This is confusing to users since we export the Session interface but seal it from external use. Following best practices, we should investigating converting the session interface to a struct.

@prestonvasquez prestonvasquez changed the base branch from v1 to master April 4, 2024 22:21
@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the priority-3-low Low Priority PR for Review label Apr 4, 2024
Copy link

mongodb-drivers-pr-bot bot commented Apr 4, 2024

API Change Report

./mongo

incompatible changes

##(Client).StartSession: changed from func(..../mongo/options.SessionOptions) (Session, error) to func(...*./mongo/options.SessionOptions) (*Session, error)
(*Client).UseSession: changed from func(context.Context, func(SessionContext) error) error to func(context.Context, func(context.Context) error) error
##(*Client).UseSessionWithOptions: changed from func(context.Context, *./mongo/options.SessionOptions, func(SessionContext) error) error to func(context.Context, *./mongo/options.SessionOptions, func(context.Context) error) error
NewSessionContext: changed from func(context.Context, Session) SessionContext to func(context.Context, Session) context.Context
##Session: changed from interface{AbortTransaction(context.Context) error; AdvanceClusterTime(./bson.Raw) error; AdvanceOperationTime(
./bson.Timestamp) error; Client() Client; ClusterTime() ./bson.Raw; CommitTransaction(context.Context) error; EndSession(context.Context); ID() ./bson.Raw; OperationTime() ./bson.Timestamp; StartTransaction(..../mongo/options.TransactionOptions) error; WithTransaction(ctx context.Context, fn func(ctx SessionContext) (interface{}, error), opts ..../mongo/options.TransactionOptions) (interface{}, error); session()} to struct{clientSession *./x/mongo/driver/session.Client; client *Client; deployment ./x/mongo/driver.Deployment; didCommitAfterStart bool}
SessionContext: removed
SessionFromContext: changed from func(context.Context) Session to func(context.Context) *Session
WithSession: changed from func(context.Context, Session, func(SessionContext) error) error to func(context.Context, *Session, func(context.Context) error) error
XSession: removed

@prestonvasquez prestonvasquez changed the title Godriver 2800 GODRIVER-2800 Convert Session Interface to a Struct Apr 4, 2024
mongo/session.go Show resolved Hide resolved
mongo/session.go Outdated Show resolved Hide resolved
mongo/with_transactions_test.go Outdated Show resolved Hide resolved
mongo/with_transactions_test.go Outdated Show resolved Hide resolved
mongo/session.go Outdated Show resolved Hide resolved
mongo/session.go Show resolved Hide resolved
mongo/session.go Outdated Show resolved Hide resolved
matthewdale
matthewdale previously approved these changes Apr 29, 2024
Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

Edit:
There are two undefined symbol compilation errors:

internal/integration/client_side_encryption_test.go:146:23: undefined: mongo.ContextWithSession
internal/integration/client_side_encryption_test.go:210:23: undefined: mongo.ContextWithSession

mongo/session.go Outdated Show resolved Hide resolved
Co-authored-by: Matt Dale <9760375+matthewdale@users.noreply.github.com>
Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@prestonvasquez prestonvasquez merged commit 3365ea1 into mongodb:master Apr 30, 2024
28 of 33 checks passed
@prestonvasquez prestonvasquez deleted the GODRIVER-2800 branch April 30, 2024 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low Low Priority PR for Review
Projects
None yet
2 participants