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

Adopt to mongo-driver v1.11.x #81

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mongoifc

import (
"context"
"time"

"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
Expand All @@ -23,6 +24,7 @@ type Client interface {
NumberSessionsInProgress() int
Ping(ctx context.Context, rp *readpref.ReadPref) error
StartSession(opts ...*options.SessionOptions) (Session, error)
Timeout() *time.Duration
UseSession(ctx context.Context, fn func(sc SessionContext) error) error
UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(sc SessionContext) error) error
Watch(
Expand Down Expand Up @@ -81,6 +83,10 @@ func (c *client) StartSession(opts ...*options.SessionOptions) (Session, error)
return wrapSession(ss, c), nil
}

func (c *client) Timeout() *time.Duration {
return c.cl.Timeout()
}

func (c *client) UseSession(ctx context.Context, fn func(sc SessionContext) error) error {
return c.cl.UseSession(ctx, wrapFn1(fn, c))
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sv-tools/mongoifc

go 1.19
go 1.20

require (
github.com/golang/mock v1.6.0
Expand Down
14 changes: 14 additions & 0 deletions mocks/gomock/mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions mocks/mockery/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,29 @@ import (
// Session is an interface for `mongo.Session` structure
// Documentation: https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Session
type Session interface {
// Functions to modify session state.

StartTransaction(opts ...*options.TransactionOptions) error
AbortTransaction(ctx context.Context) error
AdvanceClusterTime(bson.Raw) error
AdvanceOperationTime(*primitive.Timestamp) error
Client() Client
ClusterTime() bson.Raw
CommitTransaction(ctx context.Context) error
EndSession(ctx context.Context)
ID() bson.Raw
OperationTime() *primitive.Timestamp
StartTransaction(opts ...*options.TransactionOptions) error
WithTransaction(
ctx context.Context,
fn func(sc SessionContext) (interface{}, error),
opts ...*options.TransactionOptions,
) (interface{}, error)
EndSession(ctx context.Context)

// Functions to retrieve session properties.

ClusterTime() bson.Raw
OperationTime() *primitive.Timestamp
Client() Client
ID() bson.Raw

// Functions to modify mutable session properties.

AdvanceClusterTime(bson.Raw) error
AdvanceOperationTime(*primitive.Timestamp) error
}

type session struct {
Expand Down