added interface IAuthClient
This commit is contained in:
parent
a91746d474
commit
be6a01d2c7
@ -70,11 +70,17 @@ func Run(ctx context.Context, cfg initialize.Config, build Build) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
loggerForHlog := zapLogger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
|
loggerForHlog := zapLogger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
|
||||||
return zapcore.NewTee(core, clickHouseLogger)
|
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 := hlog.New(loggerForHlog).Module(initialize.ModuleLogger)
|
||||||
loggerHlog.With(models.AllFields{})
|
loggerHlog.With(models.AllFields{})
|
||||||
loggerHlog.Emit(InfoSvcStarted{})
|
loggerHlog.Emit(InfoSvcStarted{})
|
||||||
|
@ -6,6 +6,10 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type IAuthClient interface {
|
||||||
|
GetUserEmail(userID string) (string, error)
|
||||||
|
}
|
||||||
|
|
||||||
type AuthClient struct {
|
type AuthClient struct {
|
||||||
URL string
|
URL string
|
||||||
}
|
}
|
||||||
@ -42,3 +46,9 @@ func (client *AuthClient) GetUserEmail(userID string) (string, error) {
|
|||||||
|
|
||||||
return user.Email, nil
|
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 {
|
type Deps struct {
|
||||||
Dal *dal.DAL
|
Dal *dal.DAL
|
||||||
AuthClient *auth.AuthClient
|
AuthClient auth.IAuthClient
|
||||||
Producer *brokers.Producer
|
Producer *brokers.Producer
|
||||||
ServiceName string
|
ServiceName string
|
||||||
RedisClient *redis.Client
|
RedisClient *redis.Client
|
||||||
@ -29,7 +29,7 @@ type Deps struct {
|
|||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
dal *dal.DAL
|
dal *dal.DAL
|
||||||
authClient *auth.AuthClient
|
authClient auth.IAuthClient
|
||||||
producer *brokers.Producer
|
producer *brokers.Producer
|
||||||
serviceName string
|
serviceName string
|
||||||
redisClient *redis.Client
|
redisClient *redis.Client
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Clients struct {
|
type Clients struct {
|
||||||
AuthClient *auth.AuthClient
|
AuthClient auth.IAuthClient
|
||||||
//TgClient *telegram.TelegramClient
|
//TgClient *telegram.TelegramClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,8 +17,15 @@ func NewClients(ctx context.Context, cfg Config, pgDAL *dal.DAL) (*Clients, erro
|
|||||||
// return nil, err
|
// return nil, err
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
var authClient auth.IAuthClient
|
||||||
|
if cfg.IsTest {
|
||||||
|
authClient = &auth.MockAuthClient{}
|
||||||
|
} else {
|
||||||
|
authClient = auth.NewAuthClient(cfg.AuthMicroserviceURL)
|
||||||
|
}
|
||||||
|
|
||||||
return &Clients{
|
return &Clients{
|
||||||
//TgClient: tgClient,
|
//TgClient: tgClient,
|
||||||
AuthClient: auth.NewAuthClient(cfg.AuthMicroserviceURL),
|
AuthClient: authClient,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
LoggerProdMode bool `env:"IS_PROD_LOG" envDefault:"false"`
|
LoggerProdMode bool `env:"IS_PROD_LOG" envDefault:"false"`
|
||||||
IsProd bool `env:"IS_PROD" 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"`
|
ClientHttpURL string `env:"CLIENT_HTTP_URL" envDefault:"0.0.0.0:1488"`
|
||||||
GrpcURL string `env:"GRPC_URL" envDefault:"localhost:9000"`
|
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"`
|
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