Handlers, DB, Cache
This commit is contained in:
@@ -1,16 +1,32 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"payouts/internal/config"
|
||||
"context"
|
||||
|
||||
"go.uber.org/fx"
|
||||
|
||||
"payouts/internal/config"
|
||||
"payouts/internal/service/database/orm"
|
||||
)
|
||||
|
||||
var Module = fx.Options(
|
||||
fx.Provide(New),
|
||||
)
|
||||
|
||||
type DatabaseService interface {
|
||||
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
|
||||
@@ -21,6 +37,6 @@ type Params struct {
|
||||
}
|
||||
|
||||
// NewPersistence instantiates the persistence module
|
||||
func New(p Params) (DatabaseService, error) {
|
||||
return NewDatabaseService(p.AppConfig.Database.Type, p.AppConfig.Database.Connection, p.AppConfig.Database.LogLevel)
|
||||
func New(p Params) (Service, error) {
|
||||
return NewDatabaseService(p.AppConfig.Database)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user