Postgres adapter for REL.
package main
import (
"context"
_ "github.com/lib/pq"
"github.com/go-rel/postgres"
"github.com/go-rel/rel"
)
func main() {
// open postgres connection.
adapter, err := postgres.Open("postgres://postgres@localhost/rel_test?sslmode=disable")
if err != nil {
panic(err)
}
defer adapter.Close()
// initialize REL's repo.
repo := rel.New(adapter)
repo.Ping(context.TODO())
}
package main
import (
"context"
"github.com/go-rel/primaryreplica"
_ "github.com/lib/pq"
"github.com/go-rel/postgres"
"github.com/go-rel/rel"
)
func main() {
// open postgres connections.
adapter := primaryreplica.New(
postgres.MustOpen("postgres://postgres@master/rel_test?sslmode=disable"),
postgres.MustOpen("postgres://postgres@standby/rel_test?sslmode=disable"),
)
defer adapter.Close()
// initialize REL's repo.
repo := rel.New(adapter)
repo.Ping(context.TODO())
}
- github.com/lib/pq
- github.com/jackc/pgx/v5/stdlib
- PostgreSQL 11, 12, 13, 14, 15 and 16
docker run -it --rm -p 25432:5432 -e "POSTGRES_USER=rel" -e "POSTGRES_PASSWORD=rel" -e "POSTGRES_DB=rel_test" postgres:14-alpine
go test -p 1 ./...