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
|
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{
|
producer := brokers.NewProducer(brokers.ProducerDeps{
|
||||||
KafkaClient: kafkaClient,
|
KafkaClient: kafkaClient,
|
||||||
Logger: zapLogger,
|
Logger: zapLogger,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
producerGigaChat := brokers.NewProducer(brokers.ProducerDeps{
|
||||||
|
KafkaClient: gigaChatKafka,
|
||||||
|
Logger: zapLogger,
|
||||||
|
})
|
||||||
|
|
||||||
redisClient, err := initialize.Redis(ctx, cfg)
|
redisClient, err := initialize.Redis(ctx, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zapLogger.Error("Error initializing redis", zap.Error(err))
|
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)
|
go tgWC.Start(ctx)
|
||||||
|
|
||||||
controllers := initialize.NewControllers(initialize.ControllerDeps{
|
controllers := initialize.NewControllers(initialize.ControllerDeps{
|
||||||
Clients: clients,
|
Clients: clients,
|
||||||
DALs: dalS,
|
DALs: dalS,
|
||||||
Config: cfg,
|
Config: cfg,
|
||||||
Producer: producer,
|
Producer: producer,
|
||||||
RedisClient: redisClient,
|
RedisClient: redisClient,
|
||||||
|
ProducerGigaChat: producerGigaChat,
|
||||||
})
|
})
|
||||||
|
|
||||||
grpc, err := server.NewGRPC(zapLogger)
|
grpc, err := server.NewGRPC(zapLogger)
|
||||||
|
@ -10,21 +10,26 @@ import (
|
|||||||
"gitea.pena/SQuiz/core/internal/brokers"
|
"gitea.pena/SQuiz/core/internal/brokers"
|
||||||
"gitea.pena/SQuiz/core/internal/models"
|
"gitea.pena/SQuiz/core/internal/models"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
"strconv"
|
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
DAL *dal.DAL
|
DAL *dal.DAL
|
||||||
|
ProducerGigaChat *brokers.Producer
|
||||||
}
|
}
|
||||||
|
|
||||||
type Quiz struct {
|
type Quiz struct {
|
||||||
dal *dal.DAL
|
dal *dal.DAL
|
||||||
|
producerGigaChat *brokers.Producer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewQuizController(deps Deps) *Quiz {
|
func NewQuizController(deps Deps) *Quiz {
|
||||||
return &Quiz{dal: deps.DAL}
|
return &Quiz{
|
||||||
|
dal: deps.DAL,
|
||||||
|
producerGigaChat: deps.ProducerGigaChat,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateQuizReq struct {
|
type CreateQuizReq struct {
|
||||||
|
@ -24,9 +24,11 @@ type Config struct {
|
|||||||
RedisPassword string `env:"REDIS_PASSWORD" envDefault:"admin"`
|
RedisPassword string `env:"REDIS_PASSWORD" envDefault:"admin"`
|
||||||
RedisDB uint64 `env:"REDIS_DB" envDefault:"2"`
|
RedisDB uint64 `env:"REDIS_DB" envDefault:"2"`
|
||||||
|
|
||||||
CrtFile string `env:"CRT" envDefault:"server.crt"`
|
CrtFile string `env:"CRT" envDefault:"server.crt"`
|
||||||
KeyFile string `env:"KEY" envDefault:"server.key"`
|
KeyFile string `env:"KEY" envDefault:"server.key"`
|
||||||
ServiceName string `env:"SERVICE_NAME" envDefault:"squiz"`
|
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) {
|
func LoadConfig() (*Config, error) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package initialize
|
package initialize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-redis/redis/v8"
|
|
||||||
"gitea.pena/SQuiz/core/internal/brokers"
|
"gitea.pena/SQuiz/core/internal/brokers"
|
||||||
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/account"
|
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/account"
|
||||||
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/question"
|
"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/statistic"
|
||||||
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/telegram"
|
"gitea.pena/SQuiz/core/internal/controllers/http_controllers/telegram"
|
||||||
"gitea.pena/SQuiz/core/internal/controllers/rpc_controllers"
|
"gitea.pena/SQuiz/core/internal/controllers/rpc_controllers"
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ControllerDeps struct {
|
type ControllerDeps struct {
|
||||||
Clients *Clients
|
Clients *Clients
|
||||||
DALs *DALs
|
DALs *DALs
|
||||||
Config Config
|
Config Config
|
||||||
Producer *brokers.Producer
|
Producer *brokers.Producer
|
||||||
RedisClient *redis.Client
|
RedisClient *redis.Client
|
||||||
|
ProducerGigaChat *brokers.Producer
|
||||||
}
|
}
|
||||||
|
|
||||||
type Controller struct {
|
type Controller struct {
|
||||||
@ -54,7 +55,8 @@ func NewControllers(deps ControllerDeps) *Controller {
|
|||||||
DAL: deps.DALs.PgDAL,
|
DAL: deps.DALs.PgDAL,
|
||||||
}),
|
}),
|
||||||
Quiz: quiz.NewQuizController(quiz.Deps{
|
Quiz: quiz.NewQuizController(quiz.Deps{
|
||||||
DAL: deps.DALs.PgDAL,
|
DAL: deps.DALs.PgDAL,
|
||||||
|
ProducerGigaChat: deps.ProducerGigaChat,
|
||||||
}),
|
}),
|
||||||
Result: result.NewResultController(result.Deps{
|
Result: result.NewResultController(result.Deps{
|
||||||
DAL: deps.DALs.PgDAL,
|
DAL: deps.DALs.PgDAL,
|
||||||
|
Loading…
Reference in New Issue
Block a user