Skip to content

Iter23 - #23

Merged
anon-d merged 5 commits into
mainfrom
iter23
Apr 11, 2026
Merged

anon-d merged 5 commits into
mainfrom
iter23

Conversation

@anon-d

@anon-d anon-d commented Apr 5, 2026

Copy link
Copy Markdown
Owner

added link flag


var resp []handler.ItemBatchResponse
json.Unmarshal(w.Body.Bytes(), &resp)
_ = json.Unmarshal(w.Body.Bytes(), &resp)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если не обрабатываешь ошибку - как будто и не смысла возвращать _


// InsertURLsBatch вставляет набор URL в БД одним batch-запросом.
func (r *Repository) InsertURLsBatch(ctx context.Context, data []repository.Data) error {
if len(data) == 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Как будто это проверку стоит делать на слое выше - то есть на сервисе
Чтобы не ходить сюда лишний раз


for userID, urls := range urlsByUser {
query := `
UPDATE urls

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Или можешь попробовать конструктор запросов https://github.com/Masterminds/squirrel
Я пользуюсь ей - удобная штука

}

// GetURLByShortURL получает URL по короткой ссылке
func (r *Repository) GetURLByShortURL(ctx context.Context, shortURL string) (repository.Data, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно возвращать по указателю

bufferSize int
flushInterval time.Duration
logger *zap.SugaredLogger
ctx context.Context

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Контекст не хранят в структурах, а прокидывают сверху
Это написано в самом пакете

// Do not store Contexts inside a struct type; instead, pass a Context
// explicitly to each function that needs it. This is discussed further in
// https://go.dev/blog/context-and-structs. The Context should be the first
// parameter, typically named ctx:
//
// func DoSomething(ctx context.Context, arg Arg) error {
// // ... use ctx ...
// }


// Start запускает воркер: объединяет входные каналы и начинает обработку удалений.
func (w *DeleteWorker) Start() {
mergedChan := w.fanIn(w.inputChannels...)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Молодец что используешь паттерн fanIn

Comment thread internal/audit/http.go
return &HTTPObserver{
url: url,
client: &http.Client{
Timeout: 5 * time.Second,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Молодец что добавил таймаут

Comment thread internal/audit/http.go
func NewHTTPObserver(url string) *HTTPObserver {
return &HTTPObserver{
url: url,
client: &http.Client{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можешь попробовать клиент resty - мощная штука + плюс придется писать меньше кода

@anon-d
anon-d merged commit c4e1eee into main Apr 11, 2026
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