Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new PostgreSQL backend stub #3251

Merged
merged 6 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Linter fixes
  • Loading branch information
AlekSi committed Aug 25, 2023
commit 1d6468e11f613073d605125b969a70d3389ef686
10 changes: 8 additions & 2 deletions internal/backends/postgresql/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"

"github.com/FerretDB/FerretDB/internal/backends"
)
Expand All @@ -26,11 +27,16 @@ import (
type backend struct{}

// NewBackendParams represents the parameters of NewBackend function.
type NewBackendParams struct{}
//
//nolint:vet // for readability
type NewBackendParams struct {
URI string
L *zap.Logger
}

// NewBackend creates a new backend for PostgreSQL-compatible database.
func NewBackend(params *NewBackendParams) (backends.Backend, error) {
return backends.BackendContract(&backend{}), nil
return backends.BackendContract(new(backend)), nil
}

// Close implements backends.Backend interface.
Expand Down
2 changes: 2 additions & 0 deletions internal/backends/sqlite/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type backend struct {
}

// NewBackendParams represents the parameters of NewBackend function.
//
//nolint:vet // for readability
type NewBackendParams struct {
URI string
L *zap.Logger
Expand Down
5 changes: 4 additions & 1 deletion internal/handlers/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func New(opts *NewOpts) (handlers.Interface, error) {

switch opts.Backend {
case "postgresql":
b, err = postgresql.NewBackend(&postgresql.NewBackendParams{})
b, err = postgresql.NewBackend(&postgresql.NewBackendParams{
URI: opts.URI,
L: opts.L,
})
case "sqlite":
b, err = sqlite.NewBackend(&sqlite.NewBackendParams{
URI: opts.URI,
Expand Down