Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #42 from pokt-foundation/use-pgx
Browse files Browse the repository at this point in the history
feat: updated to use PGX postgres lib
  • Loading branch information
commoddity authored Nov 15, 2023
2 parents ae6fe7d + 6f8c9db commit 5c32bd0
Show file tree
Hide file tree
Showing 15 changed files with 988 additions and 424 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gen_sql:
test: test_env_up run_driver_tests test_env_down

test_env_up:
@echo "🧪 Starting up Transation DB test database ..."
@echo "🧪 Starting up Transaction DB test database ..."
@docker-compose -f ./testdata/docker-compose.test.yml up -d --remove-orphans --build
@echo "⏳ Waiting for test DB to be ready ..."
@attempts=0; while ! pg_isready -h localhost -p 5432 -U postgres -d postgres >/dev/null && [[ $$attempts -lt 5 ]]; do sleep 1; attempts=$$(($$attempts + 1)); done
Expand All @@ -27,7 +27,6 @@ run_driver_tests_ci:
init-pre-commit:
wget https://github.com/pre-commit/pre-commit/releases/download/v2.20.0/pre-commit-2.20.0.pyz
python3 pre-commit-2.20.0.pyz install
python3 pre-commit-2.20.0.pyz autoupdate
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install -v github.com/go-critic/go-critic/cmd/gocritic@latest
Expand Down
32 changes: 28 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,40 @@ module github.com/pokt-foundation/transaction-db
go 1.20

require (
cloud.google.com/go/cloudsqlconn v1.3.0
github.com/jackc/pgx/v5 v5.4.3
github.com/lib/pq v1.10.9
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.9.0
google.golang.org/grpc v1.59.0
)

require (
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.8.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
220 changes: 212 additions & 8 deletions go.sum

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions postgres-driver/db.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 42 additions & 42 deletions postgres-driver/models.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions postgres-driver/pocket_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package postgresdriver

import (
"context"
"strings"
"time"

"github.com/pokt-foundation/transaction-db/types"
Expand All @@ -18,11 +19,11 @@ func (d *PostgresDriver) WriteSession(ctx context.Context, session types.PocketS
SessionKey: session.SessionKey,
SessionHeight: int32(session.SessionHeight),
PortalRegionName: session.PortalRegionName,
CreatedAt: now,
UpdatedAt: now,
CreatedAt: newTimestamp(now),
UpdatedAt: newTimestamp(now),
})
if err != nil {
if isSpecifiedPqError(errMessageDuplicateSessionKey, err) {
if strings.Contains(err.Error(), errMessageDuplicateSessionKey) {
return types.ErrRepeatedSessionKey
}

Expand Down
Loading

0 comments on commit 5c32bd0

Please sign in to comment.