Skip to content

Commit

Permalink
Added support to close a connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Kansuler committed Nov 4, 2024
1 parent dc965bd commit 3ec0dd0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 202 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ services:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: testdb
ports:
- "5432:5432"
test:
image: golang:1.21
environment:
Expand Down
5 changes: 5 additions & 0 deletions driver/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ func (d *postgres) Begin(ctx context.Context, opts ...octobe.Option[config]) (oc
}, nil
}

// Close will close the database connection.
func (d *postgres) Close(ctx context.Context) error {
return d.pool.Close(ctx)
}

// session is a struct that holds session context, a session should be considered a series of queries that are related
// to each other. A session can be transactional or non-transactional, if it is transactional, it will enforce the usage
// of commit and rollback. If it is non-transactional, it will not enforce the usage of commit and rollback.
Expand Down
3 changes: 3 additions & 0 deletions driver/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func TestPostgres(t *testing.T) {
if !assert.NoError(t, err) {
t.FailNow()
}

err = ob.Close(ctx)
assert.NoError(t, err)
}

func Migration() postgres.Handler[octobe.Void] {
Expand Down
29 changes: 0 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,20 @@ module github.com/Kansuler/octobe/v2
go 1.21.5

require (
cloud.google.com/go/firestore v1.14.0
github.com/google/uuid v1.5.0
github.com/googleapis/gax-go/v2 v2.12.0
github.com/jackc/pgx/v5 v5.5.1
github.com/stretchr/testify v1.8.4
google.golang.org/api v0.154.0
google.golang.org/grpc v1.60.1
)

require (
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/longrunning v0.5.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // 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.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 3ec0dd0

Please sign in to comment.