func (s *Service) CommitTx(ctx context.Context) error {
	if ctx == nil {
		return errors.New("no context")
	}
	tx, ok := ctx.Value(&Tx{}).(pgx.Tx)
	if !ok {
		return errors.New("no transaction")
	}
	return tx.Commit(ctx)
}
CommitTx commits a transaction on the ops datastore.
package postgresql
import (
	"context"
	"github.com/jackc/pgx/v4"
	"github.com/pkg/errors"
)
var (
	ErrNoTransaction = errors.New("no transaction for action")
)
type Tx struct{}
func (s *Service) BeginTx(ctx context.Context) (context.Context, context.CancelFunc, error) {
	ctx, cancel := context.WithCancel(ctx)
	tx, err := s.pool.Begin(ctx)
	if err != nil {
		cancel()
		return nil, nil, errors.Wrap(err, "failed to begin transaction")
	}
	ctx = context.WithValue(ctx, &Tx{}, tx)
	return ctx, func() {
		if err := tx.Rollback(ctx); err != nil {
			log.Warn().Err(err).Msg("Failed to rollback transaction")
		}
		cancel()
	}, nil
}
func (s *Service) hasTx(ctx context.Context) bool {
	if ctx == nil {
		return false
	}
	_, ok := ctx.Value(&Tx{}).(pgx.Tx)
	return ok
}
func (s *Service) tx(ctx context.Context) pgx.Tx {
	if ctx == nil {
		return nil
	}
	if tx, ok := ctx.Value(&Tx{}).(pgx.Tx); ok {
		return tx
	}
	return nil
}