1. Задача: Реализовать production-ready менеджер для загрузки картинок по URL в хранилище с обработкой ошибок и предотвращением дублирования
package main
import (
"context"
"errors"
"fmt"
"net/http"
)
var ErrInvalidUrl = errors.New("invalid url")
type InternalImageStorageHttpClient interface {
UploadImage(ctx context.Context, url string) (int, error)
}
type ImageManagerDto struct {
id int
url string
}
type ImageManagerTable interface {
Insert(ctx context.Context, dto ImageManagerDto) error
Get(ctx context.Context, url string) (id int, ok bool, err error)
Lock(ctx context.Context, url string) error
Unlock(ctx context.Context, url string) error…