Skip to content

Commit

Permalink
Nick/neos 675 Moves sql-connector to pkg folder to be shared by worker (
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei authored Jan 26, 2024
1 parent a694c16 commit 8368867
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .mockery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ packages:
github.com/nucleuscloud/neosync/backend/internal/authmgmt/auth0:
interfaces:
Auth0MgmtClientInterface:
github.com/nucleuscloud/neosync/backend/internal/sqlconnect:
github.com/nucleuscloud/neosync/backend/pkg/sqlconnect:
interfaces:
SqlConnector:
SqlDbContainer:
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/cmds/mgmt/serve/connect/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
logging_interceptor "github.com/nucleuscloud/neosync/backend/internal/connect/interceptors/logging"
neosynclogger "github.com/nucleuscloud/neosync/backend/internal/logger"
"github.com/nucleuscloud/neosync/backend/internal/nucleusdb"
"github.com/nucleuscloud/neosync/backend/internal/sqlconnect"
clientmanager "github.com/nucleuscloud/neosync/backend/internal/temporal/client-manager"
"github.com/nucleuscloud/neosync/backend/pkg/sqlconnect"
v1alpha1_apikeyservice "github.com/nucleuscloud/neosync/backend/services/mgmt/v1alpha1/api-key-service"
v1alpha1_authservice "github.com/nucleuscloud/neosync/backend/services/mgmt/v1alpha1/auth-service"
v1alpha1_connectiondataservice "github.com/nucleuscloud/neosync/backend/services/mgmt/v1alpha1/connection-data-service"
Expand Down

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

File renamed without changes.

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

Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,28 @@ import (
"strings"

"github.com/jackc/pgx/v5/pgxpool"
mysql_queries "github.com/nucleuscloud/neosync/backend/gen/go/db/dbschemas/mysql"
pg_queries "github.com/nucleuscloud/neosync/backend/gen/go/db/dbschemas/postgresql"
mgmtv1alpha1 "github.com/nucleuscloud/neosync/backend/gen/go/protos/mgmt/v1alpha1"
nucleuserrors "github.com/nucleuscloud/neosync/backend/internal/errors"
"github.com/nucleuscloud/neosync/backend/pkg/sshtunnel"
"golang.org/x/crypto/ssh"
)

type SqlDBTX interface {
mysql_queries.DBTX

PingContext(context.Context) error
BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
}

type SqlDbContainer interface {
Open() (*sql.DB, error)
Open() (SqlDBTX, error)
Close() error
}

type PgPoolContainer interface {
Open(context.Context) (*pgxpool.Pool, error)
Open(context.Context) (pg_queries.DBTX, error)
Close()
}

Expand Down Expand Up @@ -60,7 +69,7 @@ type PgPool struct {
connectionTimeout *uint32
}

func (s *PgPool) Open(ctx context.Context) (*pgxpool.Pool, error) {
func (s *PgPool) Open(ctx context.Context) (pg_queries.DBTX, error) {
details, err := getConnectionDetails(&mgmtv1alpha1.ConnectionConfig{
Config: &mgmtv1alpha1.ConnectionConfig_PgConfig{
PgConfig: s.connectionConfig,
Expand Down Expand Up @@ -118,7 +127,7 @@ type SqlDb struct {
connectionTimeout *uint32
}

func (s *SqlDb) Open() (*sql.DB, error) {
func (s *SqlDb) Open() (SqlDBTX, error) {
details, err := getConnectionDetails(s.connectionConfig, s.connectionTimeout, s.logger)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
pg_queries "github.com/nucleuscloud/neosync/backend/gen/go/db/dbschemas/postgresql"
awsmanager "github.com/nucleuscloud/neosync/backend/internal/aws"
"github.com/nucleuscloud/neosync/backend/internal/nucleusdb"
"github.com/nucleuscloud/neosync/backend/internal/sqlconnect"
"github.com/nucleuscloud/neosync/backend/pkg/sqlconnect"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
pg_queries "github.com/nucleuscloud/neosync/backend/gen/go/db/dbschemas/postgresql"
"github.com/nucleuscloud/neosync/backend/gen/go/protos/mgmt/v1alpha1/mgmtv1alpha1connect"
awsmanager "github.com/nucleuscloud/neosync/backend/internal/aws"
"github.com/nucleuscloud/neosync/backend/internal/sqlconnect"
"github.com/nucleuscloud/neosync/backend/pkg/sqlconnect"
)

type Service struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/nucleuscloud/neosync/backend/internal/apikey"
auth_apikey "github.com/nucleuscloud/neosync/backend/internal/auth/apikey"
"github.com/nucleuscloud/neosync/backend/internal/nucleusdb"
"github.com/nucleuscloud/neosync/backend/internal/sqlconnect"
"github.com/nucleuscloud/neosync/backend/pkg/sqlconnect"
pg_models "github.com/nucleuscloud/neosync/backend/sql/postgresql/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1alpha1_connectionservice
import (
"github.com/nucleuscloud/neosync/backend/gen/go/protos/mgmt/v1alpha1/mgmtv1alpha1connect"
"github.com/nucleuscloud/neosync/backend/internal/nucleusdb"
"github.com/nucleuscloud/neosync/backend/internal/sqlconnect"
"github.com/nucleuscloud/neosync/backend/pkg/sqlconnect"
)

type Service struct {
Expand Down

0 comments on commit 8368867

Please sign in to comment.