Skip to content

Commit 4f7a258

Browse files
committed
refactor: inline withOCCRetry wrapper with occretry.Retry
The wrapper added no value over calling occretry.Retry directly.
1 parent e54fd1e commit 4f7a258

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

pkg/storage/postgres/dsql.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@ import (
55
"fmt"
66

77
"github.com/awslabs/aurora-dsql-connectors/go/pgx/dsql"
8-
"github.com/awslabs/aurora-dsql-connectors/go/pgx/occretry"
98
"github.com/jackc/pgx/v5/pgxpool"
109

1110
"github.com/openfga/openfga/pkg/storage/sqlcommon"
1211
)
1312

14-
// withOCCRetry executes fn with automatic retry on DSQL OCC errors.
15-
func withOCCRetry(ctx context.Context, fn func() error) error {
16-
return occretry.Retry(ctx, occretry.DefaultConfig(), fn)
17-
}
18-
1913
// initDSQLDB initializes a new Aurora DSQL database connection.
2014
// DSQL uses IAM authentication which the connector handles automatically.
2115
func initDSQLDB(uri string, cfg *sqlcommon.Config) (*pgxpool.Pool, error) {

pkg/storage/postgres/postgres.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"github.com/IBM/pgxpoolprometheus"
1818
sq "github.com/Masterminds/squirrel"
19+
"github.com/awslabs/aurora-dsql-connectors/go/pgx/occretry"
1920
"github.com/cenkalti/backoff/v4"
2021
"github.com/jackc/pgpassfile"
2122
"github.com/jackc/pgx/v5"
@@ -439,7 +440,7 @@ func (s *Datastore) Write(
439440
defer span.End()
440441
writeOpts := storage.NewTupleWriteOptions(opts...)
441442
if s.isDSQL {
442-
return withOCCRetry(ctx, func() error { return s.write(ctx, store, deletes, writes, writeOpts, time.Now().UTC()) })
443+
return occretry.Retry(ctx, occretry.DefaultConfig(), func() error { return s.write(ctx, store, deletes, writes, writeOpts, time.Now().UTC()) })
443444
}
444445
return s.write(ctx, store, deletes, writes, writeOpts, time.Now().UTC())
445446
}

0 commit comments

Comments
 (0)