Downloading » History » Sprint/Milestone 5
jortel@redhat.com, 08/29/2017 04:32 PM
1 | 1 | jortel@redhat.com | # Downloading |
---|---|---|---|
2 | |||
3 | 4 | jortel@redhat.com | In pulp3, there are two competing technologies and designs being considered. For the purposes of the discussion we'll name them **Jupiter** and **Saturn**. The *Jupiter* solution is based on *concurrent.futures* and the Saturn solution is based on *asyncio*. In addition to the underlying technology difference, the solutions meet the requirements in different ways. The *Jupiter* solution includes more classes, provides more abstraction and supports extension through object composition. The *Saturn* solution meets the requirements with the fewest classes possible and minimum abstraction. |
4 | 3 | jortel@redhat.com | |
5 | 5 | jortel@redhat.com | The three actors for our use cases is the *Importer*, *Streamer* and Plugin Writer. The *ChangeSet* shares a subset of the Streamer requirements but not included in this discussion. |
6 | 3 | jortel@redhat.com | |
7 | 1 | jortel@redhat.com | ## Use Cases |
8 | |||
9 | 2 | jortel@redhat.com | ### Importer |
10 | 1 | jortel@redhat.com | |
11 | 5 | jortel@redhat.com | As an importer, I need to download single files. |
12 | |||
13 | jupiter |
||
14 | |||
15 | ~~~ |
||
16 | download = HttpDownload(url, FileWriter(path)) |
||
17 | |||
18 | try: |
||
19 | download() |
||
20 | except DownloadError: |
||
21 | # An error occurred. |
||
22 | else: |
||
23 | # Go read the downloaded file \o/ |
||
24 | ~~~ |
||
25 | |||
26 | saturn |
||
27 | |||
28 | ~~~ |
||
29 | session = aiohttp.ClientSession() |
||
30 | downloader_obj = HttpDownloader(session, url) |
||
31 | downloader_coroutine = downloader_obj.run() |
||
32 | loop = asyncio._get_running_loop() |
||
33 | done, not_done = loop.run_until_complete(asyncio.wait([downloader_coroutine])) |
||
34 | for task in done: |
||
35 | try: |
||
36 | result = task.result() # This is a DownloadResult |
||
37 | except aiohttp.ClientError: |
||
38 | # An error occurred. |
||
39 | ~~~ |
||
40 | |||
41 | |||
42 | \--- |
||
43 | |||
44 | 1 | jortel@redhat.com | As an importer, I need to download files concurrently. |
45 | As an importer, I want to validate downloaded files. |
||
46 | As an importer, I am not required to keep all content (units) and artifacts in memory to support concurrent downloading. |
||
47 | As an importer, I need a way to link a downloaded file to an artifact without keeping all content units and artifacts in memory. |
||
48 | As an importer, I can perform concurrent downloading using a synchronous pattern. |
||
49 | As an importer, concurrent downloads must share resources such as sessions,connection pools and auth tokens across individual downloads. |
||
50 | As an importer I can customize how downloading is performed. For example, to support mirror lists |
||
51 | As an importer, concurrent downloading must limit the number of simultaneous connections. Downloading 5k artifacts cannot open 5k connections. |
||
52 | As an importer, I can terminate concurrent downlading at any point and not leak resources. |
||
53 | As an importer, I can download using any protocol. Starting with HTTP/HTTPS and FTP. |
||
54 | |||
55 | 2 | jortel@redhat.com | ### Streamer |
56 | 1 | jortel@redhat.com | |
57 | 4 | jortel@redhat.com | As the streamer, I need to download files related to published artifacts and metadata but delegate *the implementation* (protocol, settings, credentials) to the importer. The implementation must be a black-box. |
58 | 1 | jortel@redhat.com | As the streamer, I can download using any protocol supported by the importer. |
59 | As the streamer, I want to validate downloaded files. |
||
60 | As the streamer, concurrent downloads must share resources such as sessions,connection pools and auth tokens across individual downloads without having knowledge of such things. |
||
61 | As the streamer, I need to support complex downloading such as mirror lists. This complexity must be delegated to the importer. |
||
62 | As the streamer, I need to bridge the downloaded bit stream to the Twisted response. The file is not written to disk. |
||
63 | As the streamer, I need to forward HTTP headers from the download response to the twisted response. |
||
64 | As the streamer, I can download using (the same) custom logic as the importer such as supporting mirror lists |
||
65 | 5 | jortel@redhat.com | |
66 | h.3 Plugin Writer |
||
67 | |||
68 | As a plugin writer, I can add custom behavior to downloaders to support Mirror Lists. |