Files
payouts/internal/service/database/module.go
2026-03-10 19:17:43 +03:00

43 lines
725 B
Go

package database
import (
"context"
"go.uber.org/fx"
"payouts/internal/config"
"payouts/internal/service/database/orm"
)
var Module = fx.Options(
fx.Provide(New),
)
type params struct {
ctx context.Context
}
type Optional func(*params)
func WithContext(ctx context.Context) Optional {
return func(p *params) {
p.ctx = ctx
}
}
type Service interface {
CreateUser(user orm.User, opts ...Optional) error
GetUser(user orm.User, opts ...Optional) (orm.User, error)
}
// Params represents the module input params
type Params struct {
fx.In
AppConfig *config.App
}
// NewPersistence instantiates the persistence module
func New(p Params) (Service, error) {
return NewDatabaseService(p.AppConfig.Database)
}