Skip to content

Commit 55278b1

Browse files
committed
Update comments and pointers
1 parent ca1be9d commit 55278b1

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: go
22

33
go:
4-
- 1.11.x
4+
- 1.13.x
55
- master
66

77
script:

dump.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import (
1515
/*
1616
Data struct to configure dump behavior
1717
18-
Out: Stream to wite to
19-
Connection: Database connection to dump
20-
IgnoreTables: Mark sensitive tables to ignore
21-
LockTables: Lock all tables for the duration of the dump
18+
Out: Stream to wite to
19+
Connection: Database connection to dump
20+
IgnoreTables: Mark sensitive tables to ignore
21+
MaxAllowedPacket: Sets the largest packet size to use in backups
22+
LockTables: Lock all tables for the duration of the dump
2223
*/
2324
type Data struct {
2425
Out io.Writer
@@ -130,6 +131,9 @@ func (data *Data) Dump() error {
130131
return err
131132
}
132133

134+
// Start the read only transaction and defer the rollback until the end
135+
// This way the database will have the exact state it did at the begining of
136+
// the backup and nothing can be accidentally committed
133137
if err := data.begin(); err != nil {
134138
return err
135139
}
@@ -181,6 +185,8 @@ func (data *Data) Dump() error {
181185

182186
// MARK: - Private methods
183187

188+
// begin starts a read only transaction that will be whatever the database was
189+
// when it was called
184190
func (data *Data) begin() (err error) {
185191
data.tx, err = data.Connection.BeginTx(context.Background(), &sql.TxOptions{
186192
Isolation: sql.LevelRepeatableRead,
@@ -189,6 +195,7 @@ func (data *Data) begin() (err error) {
189195
return
190196
}
191197

198+
// rollback cancels the transaction
192199
func (data *Data) rollback() error {
193200
return data.tx.Rollback()
194201
}
@@ -294,7 +301,6 @@ func (table *table) CreateSQL() (string, error) {
294301
return tableSQL.String, nil
295302
}
296303

297-
// defer rows.Close()
298304
func (table *table) Init() (err error) {
299305
if len(table.types) != 0 {
300306
return errors.New("can't init twice")

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
module github.com/BrandonRoehl/go-mysqldump
1+
module github.com/jamf/go-mysqldump
22

33
require (
44
github.com/DATA-DOG/go-sqlmock v1.3.0
55
github.com/stretchr/testify v1.4.0
66
)
7+
8+
go 1.13

0 commit comments

Comments
 (0)