Skip to content

Commit

Permalink
universe/db/postgres: Add SendBatch to DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtverstehen committed Oct 24, 2023
1 parent 8c7c5d5 commit 064c850
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions universe/db/postgres/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package postgres

import (
"context"
"fmt"
"time"

"github.com/jackc/pgconn"
Expand Down Expand Up @@ -113,4 +114,13 @@ func (db DB) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.
return queryRow(ctx, db.opts, db.base, "db.QueryRow", sql, args...)
}

func (db DB) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults {
// Unfortunately can't introspect pgx.Batch
sql := fmt.Sprintf("batch(%d)", b.Len())
res, _ := returnWithSpan(ctx, db.opts, "db.SendBatch", sql, func(ctx context.Context) (pgx.BatchResults, error) {
return db.base.SendBatch(ctx, b), nil
})
return res
}

func (db DB) Tracer() trace.Tracer { return db.opts.t }

0 comments on commit 064c850

Please sign in to comment.