Compare commits
No commits in common. "98bb6a5bc077781bd5b9027c38f1efc2154e58e7" and "c5013c03ff331c60bd6208a7da8af3578fb58516" have entirely different histories.
98bb6a5bc0
...
c5013c03ff
8 changed files with 27 additions and 45 deletions
|
|
@ -19,4 +19,3 @@ RABBIT_PORT=
|
|||
RABBIT_USER=
|
||||
RABBIT_PASS=
|
||||
RABBIT_VHOST=
|
||||
RABBIT_LOGGING_ENABLED=
|
||||
|
|
@ -28,12 +28,11 @@ type TasksSource struct {
|
|||
}
|
||||
|
||||
type Rabbit struct {
|
||||
Host string
|
||||
Port uint16
|
||||
User string
|
||||
Pass string
|
||||
Vhost string
|
||||
LoggingEnabled bool
|
||||
Host string
|
||||
Port uint16
|
||||
User string
|
||||
Pass string
|
||||
Vhost string
|
||||
}
|
||||
|
||||
func NewConfig() Config {
|
||||
|
|
@ -51,20 +50,17 @@ func NewConfig() Config {
|
|||
},
|
||||
|
||||
TasksSource: TasksSource{
|
||||
//Host: getEnv("TASK_SOURCE_HOST", "127.0.0.1"),
|
||||
//Port: getEnv("TASK_SOURCE_PORT", "61000"),
|
||||
Host: getEnv("TASK_SOURCE_HOST", "10.0.0.1"),
|
||||
Port: getEnv("TASK_SOURCE_PORT", "9099"),
|
||||
Host: getEnv("TASK_SOURCE_HOST", "127.0.0.1"),
|
||||
Port: getEnv("TASK_SOURCE_PORT", "61000"),
|
||||
Timeout: getEnvSeconds("TASK_SOURCE_TIMEOUT_SECONDS", 60),
|
||||
},
|
||||
|
||||
Rabbit: Rabbit{
|
||||
Host: getEnv("RABBIT_HOST", "10.0.0.4"),
|
||||
Port: getEnvPort("RABBIT_PORT", 5672),
|
||||
User: getEnv("RABBIT_USER", "taskProcessorDev"),
|
||||
Pass: getEnv("RABBIT_PASS", "pass1234"),
|
||||
Vhost: getEnv("RABBIT_VHOST", "taskProcessorDevHost"),
|
||||
LoggingEnabled: getEnvBool("RABBIT_LOGGING_ENABLED", true),
|
||||
Host: getEnv("RABBIT_HOST", "10.0.0.4"),
|
||||
Port: getEnvPort("RABBIT_PORT", 5672),
|
||||
User: getEnv("RABBIT_USER", "taskProcessorDev"),
|
||||
Pass: getEnv("RABBIT_PASS", "pass1234"),
|
||||
Vhost: getEnv("RABBIT_VHOST", "taskProcessorDevHost"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,14 +50,3 @@ func getEnvPort(key string, fallback uint16) uint16 {
|
|||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
func getEnvBool(key string, fallback bool) bool {
|
||||
if value, ok := os.LookupEnv(key); ok {
|
||||
val, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
return fallback
|
||||
}
|
||||
return val
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
|
|
|||
4
go.mod
4
go.mod
|
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/sirupsen/logrus v1.9.4
|
||||
google.golang.org/grpc v1.80.0
|
||||
google.golang.org/protobuf v1.36.11
|
||||
repo.nqws.ru/merch-tracker-v2/mt-rabbit v0.1.17
|
||||
repo.nqws.ru/merch-tracker-v2/mt-rabbit v0.1.16
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
@ -15,5 +15,5 @@ require (
|
|||
golang.org/x/sys v0.42.0 // indirect
|
||||
golang.org/x/text v0.35.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
|
||||
)
|
||||
|
|
|
|||
8
go.sum
8
go.sum
|
|
@ -44,13 +44,13 @@ golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
|||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d h1:wT2n40TBqFY6wiwazVK9/iTWbsQrgk5ZfCSVFLO9LQA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
|
||||
google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
repo.nqws.ru/merch-tracker-v2/mt-rabbit v0.1.17 h1:f+oJRW0t894F9TjqG4UJAHWLcg1RffoHe5olsmYoltQ=
|
||||
repo.nqws.ru/merch-tracker-v2/mt-rabbit v0.1.17/go.mod h1:8PREIIYfA3UPigQNF+Hx+778/twVxJzI8bI8fcpVXEo=
|
||||
repo.nqws.ru/merch-tracker-v2/mt-rabbit v0.1.16 h1:bqoQZr4kblRyGQFjqBItakGm/p2PP0+68U12lLnuIYM=
|
||||
repo.nqws.ru/merch-tracker-v2/mt-rabbit v0.1.16/go.mod h1:8PREIIYfA3UPigQNF+Hx+778/twVxJzI8bI8fcpVXEo=
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ func NewApp(ctx context.Context, cfg config.Config) *App {
|
|||
Pass: cfg.Rabbit.Pass,
|
||||
Vhost: cfg.Rabbit.Vhost,
|
||||
},
|
||||
LoggingEnabled: cfg.Rabbit.LoggingEnabled,
|
||||
ChanLen: cfg.App.ProcChanLen,
|
||||
ChanLen: cfg.App.ProcChanLen,
|
||||
LoggerEnabled: false,
|
||||
})
|
||||
|
||||
return &App{
|
||||
|
|
@ -53,13 +53,11 @@ func (app *App) Run(ctx context.Context) error {
|
|||
defer mainLoop.Stop()
|
||||
|
||||
go func() {
|
||||
log.Info("Process tasks after start")
|
||||
if err := app.processor.ProcessTasks(ctx); err != nil {
|
||||
errChan <- err
|
||||
}
|
||||
|
||||
for range mainLoop.C {
|
||||
log.WithField("period", app.config.App.CheckPeriod).Info("Repeated process tasks")
|
||||
if err := app.processor.ProcessTasks(ctx); err != nil {
|
||||
errChan <- err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ type Addr struct {
|
|||
}
|
||||
|
||||
type Deps struct {
|
||||
Ctx context.Context
|
||||
TA taskAgent.TaskAgent
|
||||
Addr Addr
|
||||
ChanLen uint
|
||||
LoggingEnabled bool
|
||||
Ctx context.Context
|
||||
TA taskAgent.TaskAgent
|
||||
Addr Addr
|
||||
ChanLen uint
|
||||
LoggerEnabled bool
|
||||
}
|
||||
|
||||
func NewHandler(deps Deps) Processor {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func newService(deps Deps) *service {
|
|||
s := &service{
|
||||
taskAgent: deps.TA,
|
||||
brokerAddr: ba,
|
||||
rabbitLoggingEnabled: deps.LoggingEnabled,
|
||||
rabbitLoggingEnabled: deps.LoggerEnabled,
|
||||
}
|
||||
|
||||
s.makeTaskPublishers(deps.Ctx, ba, deps.ChanLen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue