fixing lint errors

Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
This commit is contained in:
akhilac1 2022-09-13 17:20:49 +05:30 committed by AkhilaC
parent cf413bf8fc
commit 584c80a667
2 changed files with 17 additions and 4 deletions

View File

@ -25,13 +25,15 @@ import (
"sync"
"time"
"github.com/dapr/components-contrib/configuration"
"github.com/dapr/kit/logger"
"github.com/google/uuid"
"github.com/jackc/pgconn"
"github.com/jackc/pgx"
"github.com/jackc/pgx/v4/pgxpool"
_ "github.com/jackc/pgx/v4/stdlib"
"golang.org/x/exp/utf8string"
"github.com/dapr/components-contrib/configuration"
"github.com/dapr/kit/logger"
)
type ConfigurationStore struct {
@ -55,6 +57,10 @@ const (
ErrorTooLongFieldLength = "field name is too long"
)
const (
queryKey = `SELECT * `
)
func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store {
logger.Debug("Instantiating PostgreSQL configuration store")
return &ConfigurationStore{
@ -101,7 +107,6 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ
p.logger.Error(err)
return nil, err
}
rows, err := p.client.Query(ctx, query)
if err != nil {
// If no rows exist, return an empty response, otherwise return the error.
@ -261,6 +266,13 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) {
}
func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) {
cfg, err := pgxpool.ParseConfig(conn)
if err != nil {
return nil, fmt.Errorf("postgres configuration store configuration error : %s", err)
}
cfg.AfterConnect = func(ctx context.Context, conn *pgx.Conn) {
}
pool, err := pgxpool.Connect(ctx, conn)
if err != nil {
return nil, fmt.Errorf("postgres configuration store connection error : %s", err)

View File

@ -18,8 +18,9 @@ import (
"regexp"
"testing"
"github.com/dapr/components-contrib/configuration"
"github.com/pashagolub/pgxmock"
"github.com/dapr/components-contrib/configuration"
)
func TestPostgresbuildQuery(t *testing.T) {