0c5e381434
Transactions in our code that might need to work against CockroachDB need to be retried in the event of a retryable error. The transaction helper functions in dbutil do that automatically. I am changing this code to use those helpers instead. I also fleshed out consoledb_test.go to do actual inserts and gets to make sure things were working correctly. Change-Id: I089bf4c776d15dc8578080e26760bd6dff4beec9
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package console
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// DB contains access to different satellite databases.
|
|
//
|
|
// architecture: Database
|
|
type DB interface {
|
|
// Users is a getter for Users repository.
|
|
Users() Users
|
|
// Projects is a getter for Projects repository.
|
|
Projects() Projects
|
|
// ProjectMembers is a getter for ProjectMembers repository.
|
|
ProjectMembers() ProjectMembers
|
|
// APIKeys is a getter for APIKeys repository.
|
|
APIKeys() APIKeys
|
|
// RegistrationTokens is a getter for RegistrationTokens repository.
|
|
RegistrationTokens() RegistrationTokens
|
|
// ResetPasswordTokens is a getter for ResetPasswordTokens repository.
|
|
ResetPasswordTokens() ResetPasswordTokens
|
|
// UserCredits is a getter for UserCredits repository.
|
|
UserCredits() UserCredits
|
|
|
|
// WithTx is a method for executing transactions with retrying as necessary.
|
|
WithTx(ctx context.Context, fn func(ctx context.Context, tx DBTx) error) error
|
|
}
|
|
|
|
// DBTx extends Database with transaction scope.
|
|
type DBTx interface {
|
|
DB
|
|
// Commit is a method for committing and closing transaction.
|
|
Commit() error
|
|
// Rollback is a method for rollback and closing transaction.
|
|
Rollback() error
|
|
}
|