- The ImageDownloaderApp initiates and triggers the ImageDownloaderService.
- The ImageDownloaderService retrieves batched image URLs from the FixtureLoaderExecutor.
- The ImageDownloaderService then distributes these batched image URLs among its worker pool.
- Each worker within the ImageDownloaderService processes its assigned batch of image URLs.
- Utilizing the ImageDownloaderClient, each ImageDownloaderWorker efficiently downloads the specified image URLs.
- The downloaded images are stored on the local disk by the ImageDownloaderClient.
- The ImageDownloaderApp generates a report on STDOUT, detailing downloaded images, unavailable images, skipped images, and more.
Several underlying implementations set this solution apart:
- The ImageDownloaderService employs a worker pool comprising 10 workers, with each worker capable of executing 25 concurrent download operations. This parallel approach accelerates image downloading.
- Through connection pooling, the ImageDownloaderClient optimizes HTTP requests by avoiding the overhead of establishing new connections for each call. This results in significantly reduced latency.
- The ImageDownloaderClient incorporates an HTTP retry mechanism, allowing failed calls to be retried up to three times, enhancing the solution's robustness.
- A strategic exponential backoff strategy is applied to the retry mechanism in the ImageDownloaderClient, contributing to improved reliability in the face of connectivity challenges.
- Utilizing HTTP timeouts, the ImageDownloaderClient prevents application hang-ups due to unexpectedly prolonged tasks, enhancing overall responsiveness.
- Image IDs are generated using ULID, ensuring that images with the same name do not overwrite each other, thus maintaining data integrity.
- Instead of relying solely on image extensions in URLs, the ImageDownloaderClient identifies image types based on the content type header. This versatile approach ensures accurate identification irrespective of URL structures.
To run the tests, execute the following command in your terminal:
make test
Golang 1.20
Before running the app. Please build it first. Execute this command in the terminal:
make run
Config.yml make customization:
file with URL path defined with imageurlpath batchsize also configurale. Downloaded image same path must be defined at storagerootpath
imageurlpath: "external-files/images.txt"
batchsize: 25
storagerootpath: "/go-workspace/src//getsafe/image-batch-download"