Skip to content

Commit

Permalink
Refactor providers/postgis to use pgx v4
Browse files Browse the repository at this point in the history
* refactored providers/postgis to use the pgx4 client.
Support for Postgres versions > 12 is now possible.

* provider/postgis: Properly wrap errors in messages by
moving from using %v -> %w when returning errors
in messages.

* Added error string check for context.Canceled.
The underlying net.Dial function is not properly
reporting context.Cancel errors. Becuase of this,
a string check on the error is performed. There's
an open issue for this and it appears it will be
fixed eventually but for now we have this check
to avoid unnecessary logs.

Related issue: golang/go#36208

* added ctxErr() check thewill check if the supplied
context has an error (i.e. context canceled) and if so,
return that error, else return the supplied error.
This is useful as not all of Go's stdlib has adopted
error wrapping so context.Canceled errors are not always
easy to capture.

closes #748
  • Loading branch information
iwpnd authored and ARolek committed Jan 27, 2022
1 parent 73d73af commit ec0faf2
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 184 deletions.
8 changes: 8 additions & 0 deletions atlas/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ func (m Map) encodeMVTTile(ctx context.Context, tile *slippy.Tile) ([]byte, erro
case errors.Is(err, context.Canceled):
// Do nothing if we were cancelled.

// the underlying net.Dial function is not properly reporting
// context.Canceled errors. Because of this, a string check on the error is performed.
// there's an open issue for this and it appears it will be fixed eventually
// but for now we have this check to avoid unnecessary logs
// https://github.com/golang/go/issues/36208
case strings.Contains(err.Error(), "operation was canceled"):
// Do nothing, context was canceled

default:
z, x, y := tile.ZXY()
// TODO (arolek): should we return an error to the response or just log the error?
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/go-test/deep v0.0.0-20170429201529-f49763a6ea0a
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/golang/protobuf v1.4.3
github.com/jackc/pgproto3 v1.1.0
github.com/jackc/pgproto3/v2 v2.2.0
github.com/jackc/pgtype v1.9.1
github.com/jackc/pgx/v4 v4.14.1
Expand Down
Loading

0 comments on commit ec0faf2

Please sign in to comment.