Skip to content

Commit

Permalink
Update github.com/jackc/pgx to v5 (#218)
Browse files Browse the repository at this point in the history
pgx v5 contains pgproto module with (possibly) better performance
* update pgx to v5
* fix lint
  • Loading branch information
Denchick authored Jul 17, 2023
1 parent 5b5edec commit 5049ea9
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 266 deletions.
2 changes: 1 addition & 1 deletion balancer/pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package pkg
import (
"net"

"github.com/jackc/pgproto3/v2"
"github.com/jackc/pgx/v5/pgproto3"

"github.com/pg-sharding/spqr/pkg/client"
)
Expand Down
2 changes: 1 addition & 1 deletion balancer/pkg/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"strconv"

"github.com/jackc/pgproto3/v2"
"github.com/jackc/pgx/v5/pgproto3"

"github.com/pg-sharding/spqr/pkg/client"
"github.com/pg-sharding/spqr/pkg/clientinteractor"
Expand Down
2 changes: 1 addition & 1 deletion balancer/pkg/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
"time"

_ "github.com/jackc/pgx/v4/stdlib"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/pg-sharding/spqr/pkg/spqrlog"
"golang.yandex/hasql"
"golang.yandex/hasql/checkers"
Expand Down
2 changes: 1 addition & 1 deletion balancer/pkg/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v5"
"golang.yandex/hasql"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/mover/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"os"

"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v5"
_ "github.com/lib/pq"
"github.com/pg-sharding/spqr/pkg/models/kr"
"github.com/pg-sharding/spqr/pkg/models/shrule"
Expand Down
30 changes: 15 additions & 15 deletions cmd/spqrdump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"net"

"github.com/jackc/pgproto3/v2"
"github.com/jackc/pgx/v5/pgproto3"
"github.com/spf13/cobra"
"google.golang.org/grpc"

Expand Down Expand Up @@ -81,11 +81,11 @@ func getconn() (*pgproto3.Frontend, error) {
return nil, err
}

frontend := pgproto3.NewFrontend(pgproto3.NewChunkReader(cc), cc)

if err := frontend.Send(&pgproto3.StartupMessage{
frontend := pgproto3.NewFrontend(cc, cc)
frontend.Send(&pgproto3.StartupMessage{
ProtocolVersion: conn.SSLREQ,
}); err != nil {
})
if err := frontend.Flush(); err != nil {
return nil, err
}

Expand All @@ -99,16 +99,16 @@ func getconn() (*pgproto3.Frontend, error) {
InsecureSkipVerify: true,
})

frontend = pgproto3.NewFrontend(pgproto3.NewChunkReader(cc), cc)

if err := frontend.Send(&pgproto3.StartupMessage{
frontend = pgproto3.NewFrontend(cc, cc)
frontend.Send(&pgproto3.StartupMessage{
ProtocolVersion: 196608,
Parameters: map[string]string{
"user": "user1",
"database": "spqr-console",
"password": passwd,
},
}); err != nil {
})
if err := frontend.Flush(); err != nil {
spqrlog.Logger.Printf(spqrlog.ERROR, "startup failed %v", err)
return nil, err
}
Expand All @@ -127,10 +127,10 @@ func DumpRulesPSQL() error {
if err != nil {
return err
}

if err := frontend.Send(&pgproto3.Query{
frontend.Send(&pgproto3.Query{
String: "SHOW key_ranges;",
}); err != nil {
})
if err := frontend.Flush(); err != nil {
return err
}

Expand Down Expand Up @@ -166,10 +166,10 @@ func DumpKeyRangesPSQL() error {
if err != nil {
return err
}

if err := frontend.Send(&pgproto3.Query{
frontend.Send(&pgproto3.Query{
String: "SHOW sharding_rules;",
}); err != nil {
})
if err := frontend.Flush(); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/worldmock/worldmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net"
"os"

"github.com/jackc/pgproto3/v2"
"github.com/jackc/pgx/v5/pgproto3"

"github.com/pg-sharding/spqr/pkg/config"
"github.com/pg-sharding/spqr/pkg/shard"
Expand Down
2 changes: 1 addition & 1 deletion coordinator/provider/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/pg-sharding/spqr/pkg/clientinteractor"
"github.com/pg-sharding/spqr/pkg/spqrlog"

"github.com/jackc/pgproto3/v2"
"github.com/jackc/pgx/v5/pgproto3"
"google.golang.org/grpc"

"github.com/pg-sharding/spqr/coordinator"
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ go 1.20
require (
github.com/BurntSushi/toml v1.3.2
github.com/golang/protobuf v1.5.3
github.com/jackc/pgproto3/v2 v2.3.2
github.com/jackc/pgx/v4 v4.18.1
github.com/jackc/pgx/v5 v5.4.2
github.com/jmoiron/sqlx v1.3.5
github.com/juju/errors v1.0.0
github.com/lib/pq v1.10.9
Expand All @@ -24,29 +23,30 @@ require (
github.com/xdg-go/scram v1.1.2
go.etcd.io/etcd/client/v3 v3.5.9
go.uber.org/atomic v1.11.0
golang.org/x/crypto v0.6.0
golang.org/x/crypto v0.9.0
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
golang.yandex/hasql v1.0.0
google.golang.org/grpc v1.56.2
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
)

require (
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
Expand All @@ -55,8 +55,8 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
Expand Down
Loading

0 comments on commit 5049ea9

Please sign in to comment.