added gigachatproducer
This commit is contained in:
parent
f121cc527d
commit
ba668b3539
@ -97,11 +97,26 @@ func Run(ctx context.Context, cfg initialize.Config, build Build) error {
|
||||
return err
|
||||
}
|
||||
|
||||
gigaChatKafka, err := initialize.KafkaInit(ctx, initialize.KafkaDeps{
|
||||
KafkaGroup: cfg.KafkaGroupGigaChat,
|
||||
KafkaBrokers: cfg.KafkaBrokers,
|
||||
KafkaTopic: cfg.KafkaTopicGigaChat,
|
||||
})
|
||||
if err != nil {
|
||||
zapLogger.Error("Error initializing kafka", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
producer := brokers.NewProducer(brokers.ProducerDeps{
|
||||
KafkaClient: kafkaClient,
|
||||
Logger: zapLogger,
|
||||
})
|
||||
|
||||
producerGigaChat := brokers.NewProducer(brokers.ProducerDeps{
|
||||
KafkaClient: gigaChatKafka,
|
||||
Logger: zapLogger,
|
||||
})
|
||||
|
||||
redisClient, err := initialize.Redis(ctx, cfg)
|
||||
if err != nil {
|
||||
zapLogger.Error("Error initializing redis", zap.Error(err))
|
||||
@ -130,11 +145,12 @@ func Run(ctx context.Context, cfg initialize.Config, build Build) error {
|
||||
go tgWC.Start(ctx)
|
||||
|
||||
controllers := initialize.NewControllers(initialize.ControllerDeps{
|
||||
Clients: clients,
|
||||
DALs: dalS,
|
||||
Config: cfg,
|
||||
Producer: producer,
|
||||
RedisClient: redisClient,
|
||||
Clients: clients,
|
||||
DALs: dalS,
|
||||
Config: cfg,
|
||||
Producer: producer,
|
||||
RedisClient: redisClient,
|
||||
ProducerGigaChat: producerGigaChat,
|
||||
})
|
||||
|
||||
grpc, err := server.NewGRPC(zapLogger)
|
||||
|
@ -10,21 +10,26 @@ import (
|
||||
"gitea.pena/SQuiz/core/internal/brokers"
|
||||
"gitea.pena/SQuiz/core/internal/models"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"strconv"
|
||||
"time"
|
||||
"strconv"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
type Deps struct {
|
||||
DAL *dal.DAL
|
||||
DAL *dal.DAL
|
||||
ProducerGigaChat *brokers.Producer
|
||||
}
|
||||
|
||||
type Quiz struct {
|
||||
dal *dal.DAL
|
||||
dal *dal.DAL
|
||||
producerGigaChat *brokers.Producer
|
||||
}
|
||||
|
||||
func NewQuizController(deps Deps) *Quiz {
|
||||
return &Quiz{dal: deps.DAL}
|
||||
return &Quiz{
|
||||
dal: deps.DAL,
|
||||
producerGigaChat: deps.ProducerGigaChat,
|
||||
}
|
||||
}
|
||||
|
||||
type CreateQuizReq struct {
|
||||
|
@ -24,9 +24,11 @@ type Config struct {
|
||||
RedisPassword string `env:"REDIS_PASSWORD" envDefault:"admin"`
|
||||
RedisDB uint64 `env:"REDIS_DB" envDefault:"2"`
|
||||
|
||||
CrtFile string `env:"CRT" envDefault:"server.crt"`
|
||||
KeyFile string `env:"KEY" envDefault:"server.key"`
|
||||
ServiceName string `env:"SERVICE_NAME" envDefault:"squiz"`
|
||||
CrtFile string `env:"CRT" envDefault:"server.crt"`
|
||||
KeyFile string `env:"KEY" envDefault:"server.key"`
|
||||
ServiceName string `env:"SERVICE_NAME" envDefault:"squiz"`
|
||||
KafkaGroupGigaChat string `env:"KAFKA_GROUP_GIGA_CHAT" default:"gigachat"`
|
||||
KafkaTopicGigaChat string `env:"KAFKA_TOPIC_GIGA_CHAT"`
|
||||
}
|
||||
|
||||
func LoadConfig() (*Config, error) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"github.com/go-redis/redis/v8"
|
||||
"gitea.pena/SQuiz/core/internal/brokers"
|
||||
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/account"
|
||||
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/question"
|
||||
@ -10,14 +9,16 @@ import (
|
||||
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/statistic"
|
||||
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/telegram"
|
||||
"gitea.pena/SQuiz/core/internal/controllers/rpc_controllers"
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
type ControllerDeps struct {
|
||||
Clients *Clients
|
||||
DALs *DALs
|
||||
Config Config
|
||||
Producer *brokers.Producer
|
||||
RedisClient *redis.Client
|
||||
Clients *Clients
|
||||
DALs *DALs
|
||||
Config Config
|
||||
Producer *brokers.Producer
|
||||
RedisClient *redis.Client
|
||||
ProducerGigaChat *brokers.Producer
|
||||
}
|
||||
|
||||
type Controller struct {
|
||||
@ -54,7 +55,8 @@ func NewControllers(deps ControllerDeps) *Controller {
|
||||
DAL: deps.DALs.PgDAL,
|
||||
}),
|
||||
Quiz: quiz.NewQuizController(quiz.Deps{
|
||||
DAL: deps.DALs.PgDAL,
|
||||
DAL: deps.DALs.PgDAL,
|
||||
ProducerGigaChat: deps.ProducerGigaChat,
|
||||
}),
|
||||
Result: result.NewResultController(result.Deps{
|
||||
DAL: deps.DALs.PgDAL,
|
||||
|
Loading…
Reference in New Issue
Block a user