internal

package
v0.0.0-...-2aeac8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("app",
	fx.Provide(provideConfig, provideDbConfig),
	fx.Provide(provideLogger),
	fx.Provide(provideGormDB),
	fx.Provide(provideRepository),
	fx.Provide(provideService),
	fx.Invoke(invokeMigrate),
)
View Source
var TestModule = fx.Module("test",
	fx.Provide(
		func() BuildConfig {
			_, b, _, _ := runtime.Caller(0)

			Root := filepath.Join(filepath.Dir(b), "..")
			return BuildConfig{
				ConfigFile: fmt.Sprintf("%s/config_test.yml", Root),
				Sha:        "test",
				Date:       time.UnixDate,
				DevMode:    true,
			}
		},
	),
)

Functions

func FxEvent

func FxEvent(logger *zap.Logger) fxevent.Logger

Types

type AppConfig

type AppConfig struct {
	Build     BuildConfig
	WebConfig WebConfig `yaml:"web"`
	DBConfig  DBConfig  `yaml:"database"`
}

type BuildConfig

type BuildConfig struct {
	ConfigFile string
	Sha        string
	Date       string
	DevMode    bool
}

type DBConfig

type DBConfig struct {
	Host     string `yaml:"host"`
	Port     string `yaml:"port"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	DbName   string `yaml:"database"`
	SslMode  string `yaml:"sslmode"`
}

func (DBConfig) GetDsn

func (config DBConfig) GetDsn() string

type DBContainer

type DBContainer struct {
	Container testcontainers.Container
	Config    DBConfig
}

func TestWithPostgres

func TestWithPostgres(ctx context.Context) (DBContainer, error)

type IService

type IService interface {
	SaveProduct(product Product) error
	GetProducts() ([]Product, error)
	GetProduct(id uint) (Product, error)
}

type Product

type Product struct {
	Id          uint   `json:"id"`
	Code        string `json:"code"`
	Description string `json:"description"`
	Price       uint   `json:"price"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func (Service) GetProduct

func (s Service) GetProduct(id uint) (Product, error)

func (Service) GetProducts

func (s Service) GetProducts() ([]Product, error)

func (Service) SaveProduct

func (s Service) SaveProduct(product Product) error

type WebConfig

type WebConfig struct {
	Addr string `yaml:"addr"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL