14
14
Service interface {
15
15
Pool () * pgxpool.Pool
16
16
Migrate (queries ... string ) error
17
- CreateTransaction (fn func (tx pgx.Tx ) error ) error
17
+ CreateTransaction (fn func (ctx context. Context , tx pgx.Tx ) error ) error
18
18
CreateTransactionWithCtx (
19
19
ctx context.Context ,
20
20
fn func (ctx context.Context , tx pgx.Tx ) error ,
@@ -69,7 +69,7 @@ func (d *DefaultService) Migrate(queries ...string) error {
69
69
70
70
// Create a new transaction
71
71
return d .CreateTransaction (
72
- func (tx pgx.Tx ) error {
72
+ func (ctx context. Context , tx pgx.Tx ) error {
73
73
// Execute the migration
74
74
for _ , query := range queries {
75
75
if _ , err := tx .Exec (context .Background (), query ); err != nil {
@@ -82,14 +82,19 @@ func (d *DefaultService) Migrate(queries ...string) error {
82
82
}
83
83
84
84
// CreateTransaction creates a transaction for the database
85
- func (d * DefaultService ) CreateTransaction (fn func (tx pgx.Tx ) error ) error {
85
+ func (d * DefaultService ) CreateTransaction (
86
+ fn func (
87
+ ctx context.Context ,
88
+ tx pgx.Tx ,
89
+ ) error ,
90
+ ) error {
86
91
return CreateTransaction (d .pool , fn )
87
92
}
88
93
89
94
// CreateTransactionWithCtx creates a transaction for the database with a context
90
95
func (d * DefaultService ) CreateTransactionWithCtx (
91
96
ctx context.Context ,
92
- fn func (tx pgx.Tx ) error ,
97
+ fn func (ctx context. Context , tx pgx.Tx ) error ,
93
98
) error {
94
99
return CreateTransactionWithCtx (ctx , d .pool , fn )
95
100
}
0 commit comments