chore: 🚧 remove cinemagoer and fiber and add new techinque for scraping

This commit is contained in:
2024-11-06 01:59:13 +01:00
parent 6d88e96864
commit cba9dd3ffc
46 changed files with 1179 additions and 1764 deletions
+40
View File
@@ -0,0 +1,40 @@
package repository
import (
"context"
"log/slog"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/zepyrshut/rating-orama/internal/sqlc"
)
type pgxRepository struct {
*sqlc.Queries
db *pgxpool.Pool
}
func NewPGXRepo(db *pgxpool.Pool) ExtendedQuerier {
return &pgxRepository{
Queries: sqlc.New(db),
db: db,
}
}
func (r *pgxRepository) execTx(ctx context.Context, txFunc func(tx pgx.Tx) error) error {
slog.Info("starting transaction", "txFunc", txFunc)
tx, err := r.db.Begin(ctx)
if err != nil {
slog.Error("failed to start transaction", "error", err)
return err
}
defer tx.Rollback(ctx)
if err := txFunc(tx); err != nil {
slog.Error("failed to execute transaction", "error", err)
return err
}
slog.Info("committing transaction", "txFunc", txFunc)
return tx.Commit(ctx)
}