Skip to content

Commit

Permalink
chore(pkg/server): pgsql server creation only when enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Jeronimo Irazabal <[email protected]>
  • Loading branch information
jeroiraz committed Oct 28, 2023
1 parent 3456bb5 commit 5244d10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions pkg/server/remote_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ func TestRemoteStorageUsedForNewDB(t *testing.T) {
s.WithOptions(DefaultOptions().
WithDir(dir).
WithPort(0).
WithPgsqlServer(false).
WithListener(bufconn.Listen(1024 * 1024)),
)

Expand Down
17 changes: 9 additions & 8 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,16 @@ func (s *ImmuServer) Initialize() error {
protomodel.RegisterAuthorizationServiceServer(s.GrpcServer, &authenticationServiceImp{server: s})
grpc_prometheus.Register(s.GrpcServer)

s.PgsqlSrv = pgsqlsrv.New(
pgsqlsrv.Host(s.Options.Address),
pgsqlsrv.Port(s.Options.PgsqlServerPort),
pgsqlsrv.ImmudbPort(s.Listener.Addr().(*net.TCPAddr).Port),
pgsqlsrv.TLSConfig(s.Options.TLSConfig),
pgsqlsrv.Logger(s.Logger),
pgsqlsrv.DatabaseList(s.dbList),
)
if s.Options.PgsqlServer {
s.PgsqlSrv = pgsqlsrv.New(
pgsqlsrv.Host(s.Options.Address),
pgsqlsrv.Port(s.Options.PgsqlServerPort),
pgsqlsrv.ImmudbPort(s.Listener.Addr().(*net.TCPAddr).Port),
pgsqlsrv.TLSConfig(s.Options.TLSConfig),
pgsqlsrv.Logger(s.Logger),
pgsqlsrv.DatabaseList(s.dbList),
)

if err = s.PgsqlSrv.Initialize(); err != nil {
return err
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/server/servertest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ func (bs *BufconnServer) Stop() error {
if err := bs.Server.Srv.CloseDatabases(); err != nil {
return err
}
if err := bs.Server.Srv.PgsqlSrv.Stop(); err != nil {
return err

if bs.Server.Srv.PgsqlSrv != nil {
if err := bs.Server.Srv.PgsqlSrv.Stop(); err != nil {
return err
}
}

if bs.GrpcServer != nil {
Expand Down

0 comments on commit 5244d10

Please sign in to comment.