-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
increment 15 #15
increment 15 #15
Conversation
if err := agent.Run(ctx, config); err != nil { | ||
log.Fatal(err) | ||
} | ||
agent.New().Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут можно возвращать ошибку и обрабатывать ее
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выглядит, будто незачем. Померла — так померла, не то, чтоб можно было эту ошибку как-то обработать (кроме логирования).
"github.com/nekr0z/muhame/internal/addr" | ||
"github.com/nekr0z/muhame/internal/httpclient" | ||
) | ||
|
||
type envConfig struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
декомпозицию бы сделать на config и agent ))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Учитывая, что конструктор тут — по факту, сбор конфига, эта декомпозиция скорее усложнит код, а не упростит его :(
go collect(ctx, q, config.PollInterval) | ||
go send(ctx, q, config.Address, config.ReportInterval) | ||
a.wg.Add(3) | ||
go a.collectBasic(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно сделать декомпозицию на Collector - собиратель метрик, Reporter - отправляет метрики.
Декомпозиция сложного на простое - золотое правило программирования.
internal/httpclient/client.go
Outdated
func New() Client { | ||
return Client{ | ||
c: resty.New(). | ||
SetRetryCount(3). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно вынести в config, чтобы была возможность переопределять при запуске и не было маджик намбер в коде
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пока в константу; ТЗ конфигурации не предусматривало :)
internal/agent/agent.go
Outdated
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
for range a.workers { | ||
a.wg.Add(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно сразу перед циклом написать a.wg.Add(len(a.workers))
No description provided.