-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to choose chunk time interval and wrap Pgx Connections
The new wrap will allow for better testing coverage
- Loading branch information
1 parent
975d891
commit 3cd49a4
Showing
27 changed files
with
522 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package connections | ||
|
||
import "github.com/jackc/pgx" | ||
|
||
// PgxWrap represents a wrapper interface around pgx.Conn, for easier testing. | ||
type PgxWrap interface { | ||
Begin() (*pgx.Tx, error) | ||
CopyFrom(tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int, error) | ||
Exec(sql string, arguments ...interface{}) (commandTag pgx.CommandTag, err error) | ||
Query(sql string, args ...interface{}) (*pgx.Rows, error) | ||
Close() error | ||
} | ||
|
||
type defaultPgxWrapper struct { | ||
db *pgx.Conn | ||
} | ||
|
||
// NewPgxWrapper creates a new pgx.Conn wrapper. | ||
func NewPgxWrapper(db *pgx.Conn) PgxWrap { | ||
return &defaultPgxWrapper{db} | ||
} | ||
|
||
func (d *defaultPgxWrapper) CopyFrom(tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int, error) { | ||
return d.db.CopyFrom(tableName, columnNames, rowSrc) | ||
} | ||
func (d *defaultPgxWrapper) Exec(sql string, arguments ...interface{}) (commandTag pgx.CommandTag, err error) { | ||
return d.db.Exec(sql, arguments...) | ||
} | ||
func (d *defaultPgxWrapper) Query(sql string, args ...interface{}) (*pgx.Rows, error) { | ||
return d.db.Query(sql, args...) | ||
} | ||
func (d *defaultPgxWrapper) Close() error { | ||
return d.db.Close() | ||
} | ||
func (d *defaultPgxWrapper) Begin() (*pgx.Tx, error) { | ||
return d.db.Begin() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.