one more opt to postgres.Config (SkipDBInitialization), move the queue package folder up

This commit is contained in:
Dawid Wysokiński 2021-07-11 08:33:39 +02:00
parent f2b6bbcbc4
commit bea9d67446
19 changed files with 8 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import (
"github.com/robfig/cron/v3"
"github.com/tribalwarshelp/cron/pkg/cron/queue"
"github.com/tribalwarshelp/cron/pkg/queue"
)
type Cron struct {

View File

@ -14,7 +14,8 @@ import (
var log = logrus.WithField("package", "pkg/postgres")
type Config struct {
LogQueries bool
LogQueries bool
SkipDBInitialization bool
}
func Connect(cfg *Config) (*pg.DB, error) {
@ -27,8 +28,10 @@ func Connect(cfg *Config) (*pg.DB, error) {
})
}
if err := prepareDB(db); err != nil {
return nil, err
if cfg == nil || !cfg.SkipDBInitialization {
if err := prepareDB(db); err != nil {
return nil, err
}
}
return db, nil

View File

@ -11,7 +11,7 @@ import (
"github.com/vmihailenco/taskq/v3/redisq"
)
var log = logrus.WithField("package", "pkg/cron/queue")
var log = logrus.WithField("package", "pkg/queue")
type Queue struct {
redis redis.UniversalClient