added interface IAuthClient
This commit is contained in:
parent
a91746d474
commit
be6a01d2c7
@ -75,6 +75,12 @@ func Run(ctx context.Context, cfg initialize.Config, build Build) error {
|
||||
return zapcore.NewTee(core, clickHouseLogger)
|
||||
}))
|
||||
|
||||
if cfg.IsTest {
|
||||
loggerForHlog = zapLogger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
|
||||
return zapcore.NewTee(core)
|
||||
}))
|
||||
}
|
||||
|
||||
loggerHlog := hlog.New(loggerForHlog).Module(initialize.ModuleLogger)
|
||||
loggerHlog.With(models.AllFields{})
|
||||
loggerHlog.Emit(InfoSvcStarted{})
|
||||
|
@ -6,6 +6,10 @@ import (
|
||||
"log"
|
||||
)
|
||||
|
||||
type IAuthClient interface {
|
||||
GetUserEmail(userID string) (string, error)
|
||||
}
|
||||
|
||||
type AuthClient struct {
|
||||
URL string
|
||||
}
|
||||
@ -42,3 +46,9 @@ func (client *AuthClient) GetUserEmail(userID string) (string, error) {
|
||||
|
||||
return user.Email, nil
|
||||
}
|
||||
|
||||
type MockAuthClient struct{}
|
||||
|
||||
func (m *MockAuthClient) GetUserEmail(userID string) (string, error) {
|
||||
return "test@example.com", nil
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
|
||||
type Deps struct {
|
||||
Dal *dal.DAL
|
||||
AuthClient *auth.AuthClient
|
||||
AuthClient auth.IAuthClient
|
||||
Producer *brokers.Producer
|
||||
ServiceName string
|
||||
RedisClient *redis.Client
|
||||
@ -29,7 +29,7 @@ type Deps struct {
|
||||
|
||||
type Account struct {
|
||||
dal *dal.DAL
|
||||
authClient *auth.AuthClient
|
||||
authClient auth.IAuthClient
|
||||
producer *brokers.Producer
|
||||
serviceName string
|
||||
redisClient *redis.Client
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type Clients struct {
|
||||
AuthClient *auth.AuthClient
|
||||
AuthClient auth.IAuthClient
|
||||
//TgClient *telegram.TelegramClient
|
||||
}
|
||||
|
||||
@ -17,8 +17,15 @@ func NewClients(ctx context.Context, cfg Config, pgDAL *dal.DAL) (*Clients, erro
|
||||
// return nil, err
|
||||
//}
|
||||
|
||||
var authClient auth.IAuthClient
|
||||
if cfg.IsTest {
|
||||
authClient = &auth.MockAuthClient{}
|
||||
} else {
|
||||
authClient = auth.NewAuthClient(cfg.AuthMicroserviceURL)
|
||||
}
|
||||
|
||||
return &Clients{
|
||||
//TgClient: tgClient,
|
||||
AuthClient: auth.NewAuthClient(cfg.AuthMicroserviceURL),
|
||||
AuthClient: authClient,
|
||||
}, nil
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
type Config struct {
|
||||
LoggerProdMode bool `env:"IS_PROD_LOG" envDefault:"false"`
|
||||
IsProd bool `env:"IS_PROD" envDefault:"false"`
|
||||
IsTest bool `env:"IS_TEST" envDefault:"false"`
|
||||
ClientHttpURL string `env:"CLIENT_HTTP_URL" envDefault:"0.0.0.0:1488"`
|
||||
GrpcURL string `env:"GRPC_URL" envDefault:"localhost:9000"`
|
||||
PostgresURL string `env:"POSTGRES_URL" envDefault:"host=localhost port=35432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
|
||||
|
Loading…
Reference in New Issue
Block a user