1 | | Make it possible to subscribe to an introducer, in order to learn about storage servers, without thereby announcing yourself as being a storage server. |
| 1 | Implement the new publish/subscribe introduction scheme we've been discussing |
| 2 | recently: |
| 3 | |
| 4 | * enumerate the services which can be published and queried for: |
| 5 | * upload storage server (ones which will accept new shares) |
| 6 | * download storage server (ones which will let you read shares) |
| 7 | * (soon-to-be-decommissioned storage servers will be download-only) |
| 8 | * helpers and other introducers may be added to this list, but we need |
| 9 | to talk about that more first.. I'm not sure about it. |
| 10 | |
| 11 | * all nodes should have an !IntroducerClient, as an attribute of the Node |
| 12 | instance. |
| 13 | |
| 14 | * to publish a service, do e.g.: |
| 15 | |
| 16 | {{{ |
| 17 | if self.get_config("offer_storage"): |
| 18 | ss = StorageServer() |
| 19 | ss.setServiceParent(self) |
| 20 | self.introducer.publish(ss, "upload_storage") |
| 21 | self.introducer.pushing(ss, "download_storage") |
| 22 | }}} |
| 23 | |
| 24 | * if the node cares about a particular service, it must register that intent |
| 25 | at startup: |
| 26 | |
| 27 | {{{ |
| 28 | if want_storage_servers: |
| 29 | self.introducer.subscribe_to("upload_storage") |
| 30 | self.introducer.subscribe_to("download_storage") |
| 31 | }}} |
| 32 | |
| 33 | * then, to access a service, there are two APIs: one that does permutation |
| 34 | (for upload/download) and one which just returns a flat list (mostly for |
| 35 | the welcome page): |
| 36 | |
| 37 | {{{ |
| 38 | ppeers = self.introducer.get_permuted_peers("download_storage", storage_index) |
| 39 | # ppeers is a list of (permuted_peerid, peerid, RemoteReference) |
| 40 | all_peers = self.introducer.get_peers("upload_storage") |
| 41 | }}} |
| 42 | |
| 43 | * add config flags to disable upload, and to disable storage completely. |
| 44 | Client installs (i.e. those created by py2exe) will disable storage |
| 45 | service by default. Storage-only nodes won't subscribe to hear about other |
| 46 | storage nodes. |
| 47 | |
| 48 | |
| 49 | Other things to think about: |
| 50 | |
| 51 | * get_permuted_peers could return a Deferred (which would make it easier for |
| 52 | us to create a special kind of helper which knows about peers for you), or |
| 53 | return an iterator, or both, somehow. To actually make this useful is |
| 54 | non-trivial (to reduce the memory footprint, you'd want an iterator that |
| 55 | yields Deferreds, but that might also impose a stupidly large number of |
| 56 | roundtrips to a query). We should probably wait until we identify a need |
| 57 | for this before implementing any part of it. |
| 58 | * This API implies a publish/subscribe model in which the subscription |
| 59 | accumulates knowledge about peers, and the actual point of use (i.e. |
| 60 | upload or download) samples whatever peers have been acquired by that |
| 61 | time. This might not be the best approach. |