From 5f39b07553e879f1d152b95666c89b1bf1f767f5 Mon Sep 17 00:00:00 2001 From: UnAfraid Date: Sun, 22 Oct 2023 16:02:49 +0300 Subject: [PATCH] bbolt transaction scoper cleanup --- main.go | 2 +- pkg/dbx/bbolt_transaction_scoper.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index e3162de..815a07e 100644 --- a/main.go +++ b/main.go @@ -96,7 +96,7 @@ func main() { return } - transactionScoper := dbx.NewBBoltTransactionScope(db) + transactionScoper := dbx.NewBBoltTransactionScoper(db) subscriptionImpl := subscription.NewInMemorySubscription() serverRepository := bbolt.NewServerRepository(db) diff --git a/pkg/dbx/bbolt_transaction_scoper.go b/pkg/dbx/bbolt_transaction_scoper.go index e6d6df3..97bf7ec 100644 --- a/pkg/dbx/bbolt_transaction_scoper.go +++ b/pkg/dbx/bbolt_transaction_scoper.go @@ -11,18 +11,18 @@ type contextKey struct{ name string } var bboltTxKey = contextKey{name: "bboltTxKey"} -type bboltTransactionScope struct { +type bboltTransactionScoper struct { db *bbolt.DB } -func NewBBoltTransactionScope(db *bbolt.DB) TransactionScoper { - return &bboltTransactionScope{ +func NewBBoltTransactionScoper(db *bbolt.DB) TransactionScoper { + return &bboltTransactionScoper{ db: db, } } -func (txScope *bboltTransactionScope) InTransactionScope(ctx context.Context, transactionScope func(ctx context.Context) error) (err error) { - return InBBoltTransactionScope(ctx, txScope.db, func(ctx context.Context, tx *bbolt.Tx) error { +func (bts *bboltTransactionScoper) InTransactionScope(ctx context.Context, transactionScope func(ctx context.Context) error) (err error) { + return InBBoltTransactionScope(ctx, bts.db, func(ctx context.Context, tx *bbolt.Tx) error { return transactionScope(ctx) }) }