fixing lint errors
Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
This commit is contained in:
parent
cf413bf8fc
commit
584c80a667
|
@ -25,13 +25,15 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dapr/components-contrib/configuration"
|
|
||||||
"github.com/dapr/kit/logger"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/jackc/pgconn"
|
"github.com/jackc/pgconn"
|
||||||
|
"github.com/jackc/pgx"
|
||||||
"github.com/jackc/pgx/v4/pgxpool"
|
"github.com/jackc/pgx/v4/pgxpool"
|
||||||
_ "github.com/jackc/pgx/v4/stdlib"
|
_ "github.com/jackc/pgx/v4/stdlib"
|
||||||
"golang.org/x/exp/utf8string"
|
"golang.org/x/exp/utf8string"
|
||||||
|
|
||||||
|
"github.com/dapr/components-contrib/configuration"
|
||||||
|
"github.com/dapr/kit/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigurationStore struct {
|
type ConfigurationStore struct {
|
||||||
|
@ -55,6 +57,10 @@ const (
|
||||||
ErrorTooLongFieldLength = "field name is too long"
|
ErrorTooLongFieldLength = "field name is too long"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
queryKey = `SELECT * `
|
||||||
|
)
|
||||||
|
|
||||||
func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store {
|
func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store {
|
||||||
logger.Debug("Instantiating PostgreSQL configuration store")
|
logger.Debug("Instantiating PostgreSQL configuration store")
|
||||||
return &ConfigurationStore{
|
return &ConfigurationStore{
|
||||||
|
@ -101,7 +107,6 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ
|
||||||
p.logger.Error(err)
|
p.logger.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := p.client.Query(ctx, query)
|
rows, err := p.client.Query(ctx, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If no rows exist, return an empty response, otherwise return the error.
|
// 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) {
|
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)
|
pool, err := pgxpool.Connect(ctx, conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("postgres configuration store connection error : %s", err)
|
return nil, fmt.Errorf("postgres configuration store connection error : %s", err)
|
||||||
|
|
|
@ -18,8 +18,9 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/dapr/components-contrib/configuration"
|
|
||||||
"github.com/pashagolub/pgxmock"
|
"github.com/pashagolub/pgxmock"
|
||||||
|
|
||||||
|
"github.com/dapr/components-contrib/configuration"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPostgresbuildQuery(t *testing.T) {
|
func TestPostgresbuildQuery(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue