File tree Expand file tree Collapse file tree 6 files changed +82
-62
lines changed Expand file tree Collapse file tree 6 files changed +82
-62
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,6 @@ import (
77)
88
99type (
10- // Config interface
11- Config interface {
12- DriverName () string
13- DataSourceName () string
14- MaxOpenConnections () int
15- MaxIdleConnections () int
16- ConnectionMaxLifetime () time.Duration
17- ConnectionMaxIdleTime () time.Duration
18- }
19-
2010 // ConnConfig struct
2111 ConnConfig struct {
2212 driverName string
Original file line number Diff line number Diff line change 1+ package sql
2+
3+ import (
4+ "database/sql"
5+ "time"
6+ )
7+
8+ type (
9+ // Config interface
10+ Config interface {
11+ DriverName () string
12+ DataSourceName () string
13+ MaxOpenConnections () int
14+ MaxIdleConnections () int
15+ ConnectionMaxLifetime () time.Duration
16+ ConnectionMaxIdleTime () time.Duration
17+ }
18+
19+ // Service is the interface for the service
20+ Service interface {
21+ DB () * sql.DB
22+ Migrate (queries ... string ) error
23+ CreateTransaction (fn TransactionFn ) error
24+ Exec (query * string , params ... interface {}) (sql.Result , error )
25+ QueryRow (query * string , params ... interface {}) * sql.Row
26+ ScanRow (row * sql.Row , destinations ... interface {}) error
27+ }
28+ )
Original file line number Diff line number Diff line change 1+ package pgxpool
2+
3+ import (
4+ "context"
5+ "time"
6+
7+ "github.com/jackc/pgx/v5"
8+ "github.com/jackc/pgx/v5/pgconn"
9+ "github.com/jackc/pgx/v5/pgxpool"
10+ )
11+
12+ type (
13+ // PoolHandler interface
14+ PoolHandler interface {
15+ Connect () (* pgxpool.Pool , error )
16+ Pool () (* pgxpool.Pool , error )
17+ Disconnect ()
18+ }
19+
20+ // Service is the interface for the service
21+ Service interface {
22+ Pool () * pgxpool.Pool
23+ Migrate (queries ... string ) error
24+ CreateTransaction (fn TransactionWithCtxFn ) error
25+ CreateTransactionWithCtx (
26+ ctx context.Context ,
27+ fn TransactionWithCtxFn ,
28+ ) error
29+ Exec (query * string , params ... interface {}) (* pgconn.CommandTag , error )
30+ ExecWithCtx (
31+ ctx context.Context ,
32+ query * string ,
33+ params ... interface {},
34+ ) (* pgconn.CommandTag , error )
35+ Query (query * string , params ... interface {}) (pgx.Rows , error )
36+ QueryWithCtx (
37+ ctx context.Context ,
38+ query * string ,
39+ params ... interface {},
40+ ) (pgx.Rows , error )
41+ QueryRow (query * string , params ... interface {}) (pgx.Row , error )
42+ QueryRowWithCtx (
43+ ctx context.Context ,
44+ query * string ,
45+ params ... interface {},
46+ ) (pgx.Row , error )
47+ ScanRow (row pgx.Row , destinations ... interface {}) error
48+ SetStatTicker (
49+ duration time.Duration ,
50+ fn func (* pgxpool.Stat ),
51+ )
52+ ClearStatTicker ()
53+ }
54+ )
Original file line number Diff line number Diff line change @@ -8,13 +8,6 @@ import (
88)
99
1010type (
11- // PoolHandler interface
12- PoolHandler interface {
13- Connect () (* pgxpool.Pool , error )
14- Pool () (* pgxpool.Pool , error )
15- Disconnect ()
16- }
17-
1811 // DefaultPoolHandler struct
1912 DefaultPoolHandler struct {
2013 config Config
Original file line number Diff line number Diff line change @@ -11,41 +11,6 @@ import (
1111)
1212
1313type (
14- // Service is the interface for the service
15- Service interface {
16- Pool () * pgxpool.Pool
17- Migrate (queries ... string ) error
18- CreateTransaction (fn TransactionWithCtxFn ) error
19- CreateTransactionWithCtx (
20- ctx context.Context ,
21- fn TransactionWithCtxFn ,
22- ) error
23- Exec (query * string , params ... interface {}) (* pgconn.CommandTag , error )
24- ExecWithCtx (
25- ctx context.Context ,
26- query * string ,
27- params ... interface {},
28- ) (* pgconn.CommandTag , error )
29- Query (query * string , params ... interface {}) (pgx.Rows , error )
30- QueryWithCtx (
31- ctx context.Context ,
32- query * string ,
33- params ... interface {},
34- ) (pgx.Rows , error )
35- QueryRow (query * string , params ... interface {}) (pgx.Row , error )
36- QueryRowWithCtx (
37- ctx context.Context ,
38- query * string ,
39- params ... interface {},
40- ) (pgx.Row , error )
41- ScanRow (row pgx.Row , destinations ... interface {}) error
42- SetStatTicker (
43- duration time.Duration ,
44- fn func (* pgxpool.Stat ),
45- )
46- ClearStatTicker ()
47- }
48-
4914 // DefaultService is the default service struct
5015 DefaultService struct {
5116 pool * pgxpool.Pool
Original file line number Diff line number Diff line change @@ -7,16 +7,6 @@ import (
77)
88
99type (
10- // Service is the interface for the service
11- Service interface {
12- DB () * sql.DB
13- Migrate (queries ... string ) error
14- CreateTransaction (fn TransactionFn ) error
15- Exec (query * string , params ... interface {}) (sql.Result , error )
16- QueryRow (query * string , params ... interface {}) * sql.Row
17- ScanRow (row * sql.Row , destinations ... interface {}) error
18- }
19-
2010 // DefaultService is the default service struct
2111 DefaultService struct {
2212 db * sql.DB
You can’t perform that action at this time.
0 commit comments