Skip to content

Commit

Permalink
go: add check connect for postgres
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Login <batazor@evrone.com>
  • Loading branch information
batazor committed Apr 8, 2023
1 parent 66e2f81 commit 82e1781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/pkg/db/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func (p *Store) Init(ctx context.Context) error {
return err
}

// Check connect
err = p.client.Ping(ctx)
if err != nil {
return err
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions internal/pkg/db/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (s *Store) Init(ctx context.Context) error {
return err
}

// Check connect
if _, err := s.client.Ping(ctx).Result(); err != nil {
return errors.Wrap(err, "redis ping failed")
}
Expand Down

0 comments on commit 82e1781

Please sign in to comment.