mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Implement Quotas v3 (#5012)
* provisioner/terraform: add cost to resource_metadata * provisionerd/runner: use Options struct * Complete provisionerd implementation * Add quota_allowance to groups * Combine Quota and RBAC licenses * Add Opts to InTx
This commit is contained in:
@@ -26,7 +26,7 @@ type Store interface {
|
||||
customQuerier
|
||||
|
||||
Ping(ctx context.Context) (time.Duration, error)
|
||||
InTx(func(Store) error) error
|
||||
InTx(func(Store) error, *sql.TxOptions) error
|
||||
}
|
||||
|
||||
// DBTX represents a database connection or transaction.
|
||||
@@ -68,7 +68,7 @@ func (q *sqlQuerier) Ping(ctx context.Context) (time.Duration, error) {
|
||||
}
|
||||
|
||||
// InTx performs database operations inside a transaction.
|
||||
func (q *sqlQuerier) InTx(function func(Store) error) error {
|
||||
func (q *sqlQuerier) InTx(function func(Store) error, txOpts *sql.TxOptions) error {
|
||||
if _, ok := q.db.(*sqlx.Tx); ok {
|
||||
// If the current inner "db" is already a transaction, we just reuse it.
|
||||
// We do not need to handle commit/rollback as the outer tx will handle
|
||||
@@ -80,7 +80,7 @@ func (q *sqlQuerier) InTx(function func(Store) error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
transaction, err := q.sdb.BeginTxx(context.Background(), nil)
|
||||
transaction, err := q.sdb.BeginTxx(context.Background(), txOpts)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("begin transaction: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user