Rewired db connection to store/rdbms

This commit is contained in:
Denis Arh
2020-09-08 07:54:23 +02:00
parent 75d0853c8d
commit 024e6ce890
16 changed files with 511 additions and 342 deletions
+12 -4
View File
@@ -18,8 +18,17 @@ type (
}
)
func New(ctx context.Context, dsn string) (s *Store, err error) {
var cfg *rdbms.Config
func init() {
store.Register(Connect, "postgresql", "postgres", "pgsql")
}
func Connect(ctx context.Context, dsn string) (store.Storable, error) {
var (
err error
cfg *rdbms.Config
s = new(Store)
)
if cfg, err = ProcDataSourceName(dsn); err != nil {
return nil, err
@@ -30,8 +39,7 @@ func New(ctx context.Context, dsn string) (s *Store, err error) {
cfg.SqlFunctionHandler = sqlFunctionHandler
cfg.CastModuleFieldToColumnType = fieldToColumnTypeCaster
s = new(Store)
if s.Store, err = rdbms.New(ctx, cfg); err != nil {
if s.Store, err = rdbms.Connect(ctx, cfg); err != nil {
return nil, err
}