|
1 | 1 | # parallel-download
|
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +`parallel-download` is a command that can download the resources on the web in parallel. |
| 6 | + |
| 7 | +Available options are below. |
| 8 | + |
| 9 | +| Option | Description | |
| 10 | +| --- | --- | |
| 11 | +| `-p` | Download files in parallel according to the specified number. (default 8) | |
| 12 | +| `-o` | Save the downloaded file in the specified path. (Overwrite if duplicates.) | |
| 13 | +| `-t` | Terminate when the specified value has elapsed since download started. (default 30s) | |
| 14 | + |
| 15 | +## How to develop |
| 16 | + |
| 17 | +### 1. Install packages |
| 18 | + |
| 19 | +Execute `$ dep ensure` to install dependent packages. |
| 20 | + |
| 21 | +### 2. Start a dummy server |
| 22 | + |
| 23 | +Execute `$ ./bin/dummy_server.go` to start a dummy server that returns a Gopher image. |
| 24 | + |
| 25 | +``` |
| 26 | +$ ./bin/dummy_server.go |
| 27 | +-------------------------------------------------------------------------------- |
| 28 | +# Endpoint |
| 29 | +
|
| 30 | + GET /foo.png // Get a gopher image |
| 31 | +
|
| 32 | +# Command-line options** |
| 33 | +
|
| 34 | + -failure-rate int |
| 35 | + Probability to return InternalServerError. |
| 36 | + -max-delay duration |
| 37 | + Maximum time delay randomly applied from receiving a request until returning a response. (default 1s) |
| 38 | + -port int |
| 39 | + Port on which the dummy server listens. (default 8080) |
| 40 | +-------------------------------------------------------------------------------- |
| 41 | +2018/09/30 00:25:05 Server starting on http://localhost:8080 |
| 42 | +``` |
| 43 | + |
| 44 | +### 3. Execute |
| 45 | + |
| 46 | +Execute the command with specifying the Gopher image endpoint of the dummy server (and some options). |
| 47 | + |
| 48 | +``` |
| 49 | +$ go run main.go -p=3 -t=3s -o=bar.png http://localhost:8080/foo.png |
| 50 | +start HEAD request to get Content-Length |
| 51 | +got: Accept-Ranges: bytes |
| 52 | +got: Content-Length: 169406 |
| 53 | +start GET request with header: "Range: bytes=112936-169405" |
| 54 | +start GET request with header: "Range: bytes=56468-112935" |
| 55 | +start GET request with header: "Range: bytes=0-56467" |
| 56 | +downloaded: "/var/folders/f8/1n0bk4tj4ll6clyj868k_nqh0000gn/T/parallel-download301219462/f4ec179a35" |
| 57 | +downloaded: "/var/folders/f8/1n0bk4tj4ll6clyj868k_nqh0000gn/T/parallel-download301219462/f8d59617fb" |
| 58 | +downloaded: "/var/folders/f8/1n0bk4tj4ll6clyj868k_nqh0000gn/T/parallel-download301219462/9e9b203414" |
| 59 | +concatenate downloaded files to tempfile: "/var/folders/f8/1n0bk4tj4ll6clyj868k_nqh0000gn/T/parallel-download301219462/814ff17dbf" |
| 60 | +rename "/var/folders/f8/1n0bk4tj4ll6clyj868k_nqh0000gn/T/parallel-download301219462/814ff17dbf" to "bar.png" |
| 61 | +completed: "bar.png" |
| 62 | +``` |
| 63 | + |
| 64 | +## How to run the test |
| 65 | + |
| 66 | +```shell |
| 67 | +$ make test |
| 68 | +``` |
| 69 | + |
| 70 | +## How to read GoDoc |
| 71 | + |
| 72 | +```shell |
| 73 | +$ make doc |
| 74 | +``` |
| 75 | + |
| 76 | +## How to see code coverage |
| 77 | + |
| 78 | +```shell |
| 79 | +$ make cov |
| 80 | +``` |
0 commit comments