This question is about the application's architecture and is thus language independent. Should it matter: I'm using python 3.6 and
Context and architecture
I'm writing a software that downloads some
items from an online provider. The application will run locally but the design will be done with html so I'm designing it as a web application on localhost.
There are several kinds of
item, so I have a
plugin directory. Each plugin knows how to download a specific kind of
item along with the varying meta-data. When the application loads, it instantiates every plugin. Then the server receives http requests and I have a simple for-loop that will forward the request to every plugins. By convention, only one plugin will then take control of the server to answer the request.
Here's the flow
- client sends http request
- server parses the request's endpoint and forwards to every plugins
- one plugin will recognize the endpoint and process the request
- plugins sends back an http response to server
- server forwards http response to client
Note: the plugin actually takes control of the server instance to answer. So there's coupling here. I'm happy with it because plugin depends on server instance but server does not depend on specific plugin instance.
I have a proxy plugin that must process a request and then forward it to another plugin. The problem is that the request data is passed as
POST data and there is no way in
http to forward post. The forward should require no action from the client.
I can either:
client -> server -> proxy -> client (js) -> server -> plugin2
 Send a POST request programmatically directly from the plugin. The flow will transit through the server only:
client -> server -> proxy -> server -> plugin2
 Call the other plugin's code programmatically. The flow will transit directly between the two plugins
client -> server -> proxy -> plugin2
The first two options seems hacky and the third will introduce coupling between the two plugins, which seems like a bad idea (say the second plugin's code API changes, etc.)
What's the common solution to this kind of situation? What have you done in similar situation?