Skip to content
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

Merged
merged 3 commits into from
Mar 16, 2025
Merged

increment 15 #15

merged 3 commits into from
Mar 16, 2025

Conversation

nekr0z
Copy link
Owner

@nekr0z nekr0z commented Mar 16, 2025

No description provided.

if err := agent.Run(ctx, config); err != nil {
log.Fatal(err)
}
agent.New().Run()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут можно возвращать ошибку и обрабатывать ее

Copy link
Owner Author

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

декомпозицию бы сделать на config и agent ))

Copy link
Owner Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно сделать декомпозицию на Collector - собиратель метрик, Reporter - отправляет метрики.
Декомпозиция сложного на простое - золотое правило программирования.

func New() Client {
return Client{
c: resty.New().
SetRetryCount(3).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно вынести в config, чтобы была возможность переопределять при запуске и не было маджик намбер в коде

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пока в константу; ТЗ конфигурации не предусматривало :)

ctx, cancel := context.WithCancel(context.Background())

for range a.workers {
a.wg.Add(1)
Copy link
Collaborator

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))

@nekr0z nekr0z merged commit b9e3a8f into main Mar 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants