Перенеси реализацию мессенджера из ЛР 6
Application / e2e (pull_request) Blocked by required conditions
Application / unit (pull_request) Blocked by required conditions
Skeleton contracts / contracts (pull_request) Blocked by required conditions

Источник — проверенное рабочее дерево ЛР 6 поверх 18878d6, включая изменения после повторного ревью. SHA-256 списка исходных файлов: e45a3d85b41feff1da78dce3f20fd1f4af1c5ee629e6ed703218bc8e21ad58fe.
This commit is contained in:
2026-11-30 10:54:41 +03:00
parent 20afc2c790
commit 8054913ef9
204 changed files with 23709 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
package config
import (
"fmt"
"strconv"
"time"
)
type Jobs struct {
URL string
Concurrency, MaxAttempts int
Timeout time.Duration
}
func LoadBrokerURL(lookup Lookup) (string, error) {
return secret(lookup, "BROKER_URL_FILE")
}
func LoadJobs(lookup Lookup) (Jobs, error) {
url, err := LoadBrokerURL(lookup)
if err != nil {
return Jobs{}, err
}
c := Jobs{URL: url, Concurrency: 2, MaxAttempts: 5}
seconds := 60
for _, p := range []struct {
key string
value *int
max int
}{
{"WORKER_CONCURRENCY", &c.Concurrency, 2},
{"JOB_MAX_ATTEMPTS", &c.MaxAttempts, 100},
{"JOB_TIMEOUT_SECONDS", &seconds, 3600},
} {
if s, ok := lookup(p.key); ok {
n, err := strconv.Atoi(s)
if err != nil || n < 1 || n > p.max {
return Jobs{}, fmt.Errorf("%s must be between 1 and %d", p.key, p.max)
}
*p.value = n
}
}
c.Timeout = time.Duration(seconds) * time.Second
return c, nil
}