Skip to content

Commit

Permalink
bbolt transaction scoper cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
UnAfraid committed Oct 22, 2023
1 parent 22535a4 commit aefcc93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func main() {
return
}

transactionScoper := dbx.NewBBoltTransactionScope(db)
transactionScoper := dbx.NewBBoltTransactionScoper(db)
subscriptionImpl := subscription.NewInMemorySubscription()

serverRepository := bbolt.NewServerRepository(db)
Expand All @@ -115,7 +115,6 @@ func main() {
}

var wireguardBackend backend.Backend

switch strings.ToLower(conf.Backend) {
case "linux":
wireguardBackend, err = linux.NewLinuxBackend()
Expand Down
10 changes: 5 additions & 5 deletions pkg/dbx/bbolt_transaction_scoper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit aefcc93

Please sign in to comment.