Skip to content

Commit

Permalink
Documentation and linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kugelschieber committed Aug 30, 2020
1 parent 0bcf1b3 commit 54cc3f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ func (store *PostgresStore) VisitorsPerPlatform(tenantID sql.NullInt64) []Visito
return entities
}

// NewTx implements the Store interface.
func (store *PostgresStore) NewTx() *sqlx.Tx {
tx, err := store.DB.Beginx()

Expand All @@ -998,12 +999,14 @@ func (store *PostgresStore) NewTx() *sqlx.Tx {
return tx
}

// Commit implements the Store interface.
func (store *PostgresStore) Commit(tx *sqlx.Tx) {
if err := tx.Commit(); err != nil {
store.logger.Printf("error committing transaction: %s", err)
}
}

// Rollback implements the Store interface.
func (store *PostgresStore) Rollback(tx *sqlx.Tx) {
if err := tx.Rollback(); err != nil {
store.logger.Printf("error rolling back transaction: %s", err)
Expand Down
3 changes: 3 additions & 0 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ type Store interface {
// VisitorsPerPlatform returns all visitor platforms for given tenant ID sorted by days.
VisitorsPerPlatform(sql.NullInt64) []VisitorPlatform

// NewTx creates a new transaction and panic on failure.
NewTx() *sqlx.Tx

// Commit commits given transaction and logs the error.
Commit(*sqlx.Tx)

// Rollback rolls back given transaction and logs the error.
Rollback(*sqlx.Tx)
}

0 comments on commit 54cc3f2

Please sign in to comment.