Skip to content

Commit

Permalink
Expanded DB interface and added seed info config
Browse files Browse the repository at this point in the history
  • Loading branch information
smgladkovskiy committed Nov 17, 2021
1 parent bf68b8e commit 7e47e9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 13 additions & 2 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ const (
cfgValidationErrorFormat = "%s: %w - %s"
)

type SeedInfo struct {
Enabled bool `yaml:"enabled"`
Name string `yaml:"name"`
Description string `yaml:"description"`
ClassName string `yaml:"class_name"`
}

type SeedingCfg struct {
RunOnStart bool `yaml:"run_on_start"`
Seeds []string `yaml:"seeds"`
RunOnStart bool `yaml:"run_on_start"`
Seeds []SeedInfo `yaml:"seeds"`
}

type MigrationCfg struct {
Expand Down Expand Up @@ -91,6 +98,10 @@ func (d Database) GetSchema() string {
return d.Schema
}

func (d Database) GetConnectionParams() (maxConnLifetime time.Duration, maxConns, minConns int32) {
return d.ConnectionLifeTime, int32(d.MaxOpenConnections), int32(d.MaxIdleConnections)
}

var (
ErrDataIsEmpty = errors.New("data is empty")
ErrDataIsInvalid = errors.New("data is invalid")
Expand Down
6 changes: 6 additions & 0 deletions interfaces.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package cfgstructs

import (
"time"
)

type Config interface {
ValidateAll() []error
}
Expand All @@ -23,6 +27,8 @@ type DatabaseCfgInterface interface {

GetSchema() string
GetMigrationsTableName() string

GetConnectionParams() (maxConnLifetime time.Duration, maxConns, minConns int32)
}

type NSQQueueCfgInterface interface {
Expand Down

0 comments on commit 7e47e9d

Please sign in to comment.