50 lines
1 KiB
Go
50 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"git.sch9.ru/new_gate/ms-runner/config"
|
|
runnerPubSub "git.sch9.ru/new_gate/ms-runner/internal/runner/delivery/rabbitmq"
|
|
runnerUseCase "git.sch9.ru/new_gate/ms-runner/internal/runner/usecase"
|
|
"git.sch9.ru/new_gate/ms-runner/pkg/external/rabbitmq"
|
|
"github.com/ilyakaznacheev/cleanenv"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
func main() {
|
|
var cfg config.Config
|
|
err := cleanenv.ReadConfig(".env", &cfg)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("error reading config: %s", err.Error()))
|
|
}
|
|
|
|
conn, err := rabbitmq.NewRabbitClient(cfg.RabbitDSN)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer conn.Close()
|
|
ch, err := conn.Channel()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer ch.Close()
|
|
err = ch.Qos(
|
|
1,
|
|
0,
|
|
true,
|
|
)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
runnerUC := runnerUseCase.NewRunnerUseCase(10)
|
|
runnerPubSub.NewRunnerBuilderProducer(ch, runnerUC)
|
|
runnerPubSub.NewRunnerBuilderConsumer(ch, runnerUC, cfg.TQueueName, cfg.InstanceName)
|
|
|
|
stop := make(chan os.Signal, 1)
|
|
signal.Notify(stop, syscall.SIGTERM, syscall.SIGINT)
|
|
|
|
<-stop
|
|
}
|