From 4287cd42b25cecddb1dcae61d30f2cd06ade24c4 Mon Sep 17 00:00:00 2001 From: Piyush Chauhan <42397980+pyshx@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:59:44 +0530 Subject: [PATCH] fix(mongox): transaction read pref should be primary (#43) --- mongox/transaction.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mongox/transaction.go b/mongox/transaction.go index d9f9e95..4f926f1 100644 --- a/mongox/transaction.go +++ b/mongox/transaction.go @@ -7,7 +7,6 @@ import ( "github.com/reearth/reearthx/usecasex" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" "go.mongodb.org/mongo-driver/x/mongo/driver" ) @@ -24,13 +23,7 @@ func NewTransaction(client *mongo.Client) *Transaction { } func (t *Transaction) Begin(ctx context.Context) (usecasex.Tx, error) { - // Set the read preference to Nearest - rp := readpref.Nearest() - - // Create session options with the Nearest read preference - sessionOpts := options.Session().SetDefaultReadPreference(rp) - - s, err := t.client.StartSession(sessionOpts) + s, err := t.client.StartSession(options.Session()) if err != nil { return nil, err }