swift-toolkit icon indicating copy to clipboard operation
swift-toolkit copied to clipboard

EpubServer: Don't instantiate X handlers per epub being served

Open ghost opened this issue 7 years ago • 4 comments

Currently, for each epub being served the EpubServer object creates 2 handlers, one for the manifest and one for the ressources .

As it is right now if it serves 20 epubs, there will be 40 handlers.

Instead, the server should only have 2 (or more, depending of the needs) handlers, and they should be called with a parameter (a hash or some id - TBD) to decide which ressource they serve. The routing to the ressource would be made inside the handler() instead of being directly made in the URL.

That would also fix the following problem: when wanting to remove an Epub being served from the server, we don't have the id associated to the handlers serving it, hence we can't remove these handlers.

ghost avatar Mar 02 '17 14:03 ghost

@camill-a Yes, indeed. The parameter should be a unique publication identifier, but I think it's the responsability of this API client to provide it (as it is now).

olivierkorner avatar Mar 03 '17 09:03 olivierkorner

Is this still relevant? cc @mickael-menu @aferditamuriqi

HadrienGardeur avatar Jan 22 '20 10:01 HadrienGardeur

Yes, it looks like it: https://github.com/readium/r2-streamer-swift/blob/630d8953cbad98fb229233caa9d98b2ce16474b3/r2-streamer-swift/Server/PublicationServer.swift#L140-L146

mickael-menu avatar Jan 22 '20 14:01 mickael-menu

Blocked until https://github.com/readium/swift-toolkit/issues/117 is resolved

mickael-menu avatar Feb 08 '21 16:02 mickael-menu