Skip to content

Commit 626199b

Browse files
committed
Renamed builds to remove adapter word duplication
1 parent c7baa44 commit 626199b

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
"github.com/jackc/pgx"
3030
pg "github.com/vgarvardt/go-oauth2-pg"
31-
pgxAdapter "github.com/vgarvardt/go-oauth2-pg/adapter/pgx"
31+
pgxAdapter "github.com/vgarvardt/go-oauth2-pg/pgx_adapter"
3232
"gopkg.in/oauth2.v3/manage"
3333
)
3434

@@ -39,7 +39,7 @@ func main() {
3939
manager := manage.NewDefaultManager()
4040

4141
// use PostgreSQL token store with pgx.Connection adapter
42-
store, _ := pg.NewStore(pgxAdapter.NewConnAdapter(pgxConn), pg.WithGCInterval(time.Minute))
42+
store, _ := pg.NewStore(pgxAdapter.NewConn(pgxConn), pg.WithGCInterval(time.Minute))
4343
defer store.Close()
4444

4545
manager.MapTokenStorage(store)

pgx_adapter/adapter.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@ import (
66
pgxHelpers "github.com/vgarvardt/pgx-helpers"
77
)
88

9-
// ConnPoolAdapter is the adapter type for PGx connection pool connection type
10-
type ConnPoolAdapter struct {
9+
// ConnPool is the adapter type for PGx connection pool connection type
10+
type ConnPool struct {
1111
conn *pgx.ConnPool
1212
}
1313

14-
// NewConnPoolAdapter instantiates PGx connection pool adapter
15-
func NewConnPoolAdapter(conn *pgx.ConnPool) *ConnPoolAdapter {
16-
return &ConnPoolAdapter{conn}
14+
// NewConnPool instantiates PGx connection pool adapter
15+
func NewConnPool(conn *pgx.ConnPool) *ConnPool {
16+
return &ConnPool{conn}
1717
}
1818

19-
// ConnAdapter is the adapter type for PGx connection connection type
20-
type ConnAdapter struct {
19+
// Conn is the adapter type for PGx connection connection type
20+
type Conn struct {
2121
conn *pgx.Conn
2222
}
2323

24-
// NewConnAdapter instantiates PGx connection adapter
25-
func NewConnAdapter(conn *pgx.Conn) *ConnAdapter {
26-
return &ConnAdapter{conn}
24+
// NewConn instantiates PGx connection adapter
25+
func NewConn(conn *pgx.Conn) *Conn {
26+
return &Conn{conn}
2727
}
2828

2929
// Exec runs a query and returns an error if any
30-
func (a *ConnPoolAdapter) Exec(query string, args ...interface{}) error {
30+
func (a *ConnPool) Exec(query string, args ...interface{}) error {
3131
_, err := a.conn.Exec(query, args...)
3232
return err
3333
}
3434

3535
// SelectOne runs a select query and scans the object into a struct or returns an error
36-
func (a *ConnPoolAdapter) SelectOne(dst interface{}, query string, args ...interface{}) error {
36+
func (a *ConnPool) SelectOne(dst interface{}, query string, args ...interface{}) error {
3737
row := a.conn.QueryRow(query, args...)
3838
if err := pgxHelpers.ScanStruct(row, dst); err != nil {
3939
if err == pgx.ErrNoRows {
@@ -46,13 +46,13 @@ func (a *ConnPoolAdapter) SelectOne(dst interface{}, query string, args ...inter
4646
}
4747

4848
// Exec runs a query and returns an error if any
49-
func (a *ConnAdapter) Exec(query string, args ...interface{}) error {
49+
func (a *Conn) Exec(query string, args ...interface{}) error {
5050
_, err := a.conn.Exec(query, args...)
5151
return err
5252
}
5353

5454
// SelectOne runs a select query and scans the object into a struct or returns an error
55-
func (a *ConnAdapter) SelectOne(dst interface{}, query string, args ...interface{}) error {
55+
func (a *Conn) SelectOne(dst interface{}, query string, args ...interface{}) error {
5656
row := a.conn.QueryRow(query, args...)
5757
if err := pgxHelpers.ScanStruct(row, dst); err != nil {
5858
if err == pgx.ErrNoRows {

pgx_adapter/adapter_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func generateTableName() string {
5353
return fmt.Sprintf("token_%d", time.Now().UnixNano())
5454
}
5555

56-
func TestNewConnAdapter(t *testing.T) {
56+
func TestNewConn(t *testing.T) {
5757
l := new(memoryLogger)
5858

5959
pgxConnConfig, err := pgx.ParseURI(uri)
@@ -68,7 +68,7 @@ func TestNewConnAdapter(t *testing.T) {
6868
assert.NoError(t, pgxConn.Close())
6969
}()
7070

71-
adapter := NewConnAdapter(pgxConn)
71+
adapter := NewConn(pgxConn)
7272
tableName := generateTableName()
7373

7474
store, err := pg.NewStore(adapter, pg.WithLogger(l), pg.WithTableName(tableName), pg.WithGCInterval(time.Second))
@@ -80,7 +80,7 @@ func TestNewConnAdapter(t *testing.T) {
8080
runStoreTest(t, store, l)
8181
}
8282

83-
func TestNewConnPoolAdapter(t *testing.T) {
83+
func TestNewConnPool(t *testing.T) {
8484
l := new(memoryLogger)
8585

8686
pgxConnConfig, err := pgx.ParseURI(uri)
@@ -95,7 +95,7 @@ func TestNewConnPoolAdapter(t *testing.T) {
9595

9696
defer pgXConnPool.Close()
9797

98-
adapter := NewConnPoolAdapter(pgXConnPool)
98+
adapter := NewConnPool(pgXConnPool)
9999
tableName := generateTableName()
100100

101101
store, err := pg.NewStore(adapter, pg.WithLogger(l), pg.WithTableName(tableName), pg.WithGCInterval(time.Second))

sql_adapter/adapter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ type Adapter struct {
1111
conn *sqlx.DB
1212
}
1313

14-
// NewSQL instantiates sqlx.DB connection adapter from sql.DB connection
15-
func NewSQL(conn *sql.DB) *Adapter {
14+
// New instantiates sqlx.DB connection adapter from sql.DB connection
15+
func New(conn *sql.DB) *Adapter {
1616
// The driverName of the original database is required for named query support - we do not use it here
1717
return &Adapter{sqlx.NewDb(conn, "")}
1818
}
1919

20-
// NewSQLx instantiates sqlx.DB connection adapter
21-
func NewSQLx(conn *sqlx.DB) *Adapter {
20+
// NewX instantiates sqlx.DB connection adapter
21+
func NewX(conn *sqlx.DB) *Adapter {
2222
return &Adapter{conn}
2323
}
2424

sql_adapter/adapter_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func generateTableName() string {
4141
return fmt.Sprintf("token_%d", time.Now().UnixNano())
4242
}
4343

44-
func TestNewSQL(t *testing.T) {
44+
func TestNew(t *testing.T) {
4545
l := new(memoryLogger)
4646

4747
conn, err := sql.Open("pgx", uri)
@@ -51,7 +51,7 @@ func TestNewSQL(t *testing.T) {
5151
assert.NoError(t, conn.Close())
5252
}()
5353

54-
adapter := NewSQL(conn)
54+
adapter := New(conn)
5555
tableName := generateTableName()
5656

5757
store, err := pg.NewStore(adapter, pg.WithLogger(l), pg.WithTableName(tableName), pg.WithGCInterval(time.Second))
@@ -63,7 +63,7 @@ func TestNewSQL(t *testing.T) {
6363
runStoreTest(t, store, l)
6464
}
6565

66-
func TestNewSQLx(t *testing.T) {
66+
func TestNewX(t *testing.T) {
6767
l := new(memoryLogger)
6868

6969
conn, err := sql.Open("pgx", uri)
@@ -73,7 +73,7 @@ func TestNewSQLx(t *testing.T) {
7373
assert.NoError(t, conn.Close())
7474
}()
7575

76-
adapter := NewSQLx(sqlx.NewDb(conn, ""))
76+
adapter := NewX(sqlx.NewDb(conn, ""))
7777
tableName := generateTableName()
7878

7979
store, err := pg.NewStore(adapter, pg.WithLogger(l), pg.WithTableName(tableName), pg.WithGCInterval(time.Second))

0 commit comments

Comments
 (0)