log enabled dep
This commit is contained in:
parent
c5013c03ff
commit
b29e60b712
6 changed files with 39 additions and 21 deletions
|
|
@ -19,3 +19,4 @@ RABBIT_PORT=
|
|||
RABBIT_USER=
|
||||
RABBIT_PASS=
|
||||
RABBIT_VHOST=
|
||||
RABBIT_LOGGING_ENABLED=
|
||||
|
|
@ -33,6 +33,7 @@ type Rabbit struct {
|
|||
User string
|
||||
Pass string
|
||||
Vhost string
|
||||
LoggingEnabled bool
|
||||
}
|
||||
|
||||
func NewConfig() Config {
|
||||
|
|
@ -50,8 +51,10 @@ 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", "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"),
|
||||
Timeout: getEnvSeconds("TASK_SOURCE_TIMEOUT_SECONDS", 60),
|
||||
},
|
||||
|
||||
|
|
@ -61,6 +64,7 @@ func NewConfig() Config {
|
|||
User: getEnv("RABBIT_USER", "taskProcessorDev"),
|
||||
Pass: getEnv("RABBIT_PASS", "pass1234"),
|
||||
Vhost: getEnv("RABBIT_VHOST", "taskProcessorDevHost"),
|
||||
LoggingEnabled: getEnvBool("RABBIT_LOGGING_ENABLED", true),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,3 +50,14 @@ 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
LoggerEnabled: false,
|
||||
})
|
||||
|
||||
return &App{
|
||||
|
|
@ -53,11 +53,13 @@ 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ type Deps struct {
|
|||
TA taskAgent.TaskAgent
|
||||
Addr Addr
|
||||
ChanLen uint
|
||||
LoggerEnabled bool
|
||||
LoggingEnabled bool
|
||||
}
|
||||
|
||||
func NewHandler(deps Deps) Processor {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func newService(deps Deps) *service {
|
|||
s := &service{
|
||||
taskAgent: deps.TA,
|
||||
brokerAddr: ba,
|
||||
rabbitLoggingEnabled: deps.LoggerEnabled,
|
||||
rabbitLoggingEnabled: deps.LoggingEnabled,
|
||||
}
|
||||
|
||||
s.makeTaskPublishers(deps.Ctx, ba, deps.ChanLen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue