Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
efritz committed Sep 12, 2024
1 parent 2c8613d commit ede72cc
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 229 deletions.
2 changes: 1 addition & 1 deletion cmd/migrate/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"

"github.com/go-nacelle/nacelle"
"github.com/go-nacelle/nacelle/v2"
"github.com/go-nacelle/pgutil"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/drift.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"os"

"github.com/go-nacelle/nacelle"
"github.com/go-nacelle/nacelle/v2"
"github.com/go-nacelle/pgutil"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/go-nacelle/nacelle"
"github.com/go-nacelle/nacelle/v2"
"github.com/go-nacelle/pgutil"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"time"

"github.com/go-nacelle/nacelle"
"github.com/go-nacelle/nacelle/v2"
)

type DB interface {
Expand Down
2 changes: 1 addition & 1 deletion db_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"time"

"github.com/go-nacelle/nacelle"
"github.com/go-nacelle/nacelle/v2"
)

type loggingTx struct {
Expand Down
24 changes: 22 additions & 2 deletions db_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"
"testing"

"github.com/go-nacelle/log/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -61,7 +62,7 @@ func TestTransaction(t *testing.T) {
func TestConcurrentTransactions(t *testing.T) {
t.Run("creating transactions concurrently does not fail", func(t *testing.T) {
shim := &captureShim{}
db := NewTestDBWithLogger(t, adaptShim(shim))
db := NewTestDBWithLogger(t, log.FromMinimalLogger(shim))
setupTestTransactionTable(t, db)

var g errgroup.Group
Expand Down Expand Up @@ -95,7 +96,7 @@ func TestConcurrentTransactions(t *testing.T) {

t.Run("parallel insertion on a single transaction does not fail but logs an error", func(t *testing.T) {
shim := &captureShim{}
db := NewTestDBWithLogger(t, adaptShim(shim))
db := NewTestDBWithLogger(t, log.FromMinimalLogger(shim))
setupTestTransactionTable(t, db)

tx, err := db.Transact(context.Background())
Expand Down Expand Up @@ -201,3 +202,22 @@ func testTableContents(t *testing.T, db DB) map[int]int {

return pairsMap
}

//
//

type captureShim struct {
logs []string
}

func (n *captureShim) WithFields(log.LogFields) log.MinimalLogger {
return n
}

func (n *captureShim) LogWithFields(level log.LogLevel, fields log.LogFields, format string, args ...interface{}) {
n.logs = append(n.logs, fmt.Sprintf(format, args...))
}

func (n *captureShim) Sync() error {
return nil
}
2 changes: 1 addition & 1 deletion db_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/go-nacelle/nacelle"
"github.com/go-nacelle/nacelle/v2"
)

type queryWrapper struct {
Expand Down
2 changes: 1 addition & 1 deletion dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"time"

"github.com/go-nacelle/nacelle"
"github.com/go-nacelle/nacelle/v2"
)

const MaxPingAttempts = 15
Expand Down
37 changes: 14 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/go-nacelle/pgutil
go 1.21

require (
github.com/go-nacelle/log v1.0.1
github.com/go-nacelle/nacelle v1.1.0
github.com/go-nacelle/log/v2 v2.0.1
github.com/go-nacelle/nacelle/v2 v2.1.1
github.com/google/go-cmp v0.6.0
github.com/jackc/pgconn v1.14.1
github.com/lib/pq v1.10.9
Expand All @@ -16,38 +16,29 @@ require (
)

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/aphistic/gomol v0.0.0-20190314031446-1546845ba714 // indirect
github.com/aphistic/gomol-console v0.0.0-20180111152223-9fa1742697a8 // indirect
github.com/aphistic/sweet v0.3.0 // indirect
github.com/aphistic/sweet-junit v0.2.0 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/efritz/backoff v1.0.0 // indirect
github.com/efritz/glock v0.0.0-20181228234553-f184d69dff2c // indirect
github.com/efritz/watchdog v0.0.0-20181228234521-84cf7cb74656 // indirect
github.com/fatih/structtag v1.0.0 // indirect
github.com/derision-test/glock v1.1.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-nacelle/config v1.1.0 // indirect
github.com/go-nacelle/process v1.0.0 // indirect
github.com/go-nacelle/service v1.0.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/go-nacelle/config/v3 v3.0.0 // indirect
github.com/go-nacelle/process/v2 v2.1.0 // indirect
github.com/go-nacelle/service/v2 v2.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/mattn/go-zglob v0.0.1 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/onsi/gomega v1.7.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-zglob v0.0.6 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit ede72cc

Please sign in to comment.