0

Yay or nay? I have several related but separate services that are to be run in different processes. They execute a particular task unique to the service. Their call signature is similar, but the name of the service changes. For example.

Service 1:
:5000/Invoice/<id>
:5000/Customer/<id>

Service 2:
:5001/Invoice/<id>
:5001/Customer/<id>

Each of the calls has e.g. GET and POST methods associated with it. I'd like to refactor this to be:

:5000/Invoice/<id>/service1
:5000/Customer/<id>/service1
:5000/Invoice/<id>/service2
:5000/Customer/<id>/service2

These calls would then delegate to the services themselves. Notice there is only one port or address to call the entire service instead of a port for each service on its own. So I'm thinking that adding a layer that calls the relevant service locally would be the way to go.

Is this a good approach? Is it more intuitive? It does add a layer of calling things again, so it might introduce some delay to requests, but maybe the trade off is worth it. Are there other ways of doing it? I'm rather new to web development, so I don't know much about common practices. If it makes a difference, I'm using Python and Flask.


There is one service that is used more often and the others and is more critical. Perhaps the other requests could be routed through that service.

  • 2
    This question is unanswerable without having meaningful names for the services, actions, etc. Also, are you trying to follow the REST guidelines for your API? – Bart van Ingen Schenau Jan 4 at 8:57
  • So you would like to replace, say, Customer/Get, Customer/Delete, Invoice/Get, Invoice/Delete with Get/variable and Close/variable? Using a verb (action) as a service name seems really odd to me. It's not intuitive. But maybe I didn't understood what you're asking for... – Sylvain Rodrigue Jan 4 at 9:43
  • @SylvainRodrigue I didn't mean HTML verbs as actions. My bad. It just represents a path. Variable is the ID so to speak and each method would have GET and POST for example. – Felix Jan 4 at 9:50
  • @SylvainRodrigue I edited the question to hopefully be clearer. – Felix Jan 4 at 10:01
  • @BartvanIngenSchenau Hopefully the situation is better now. I'm trying to follow best practices, but for starters in this particular case the executed actions do change internal state, as intended. So I'm not too rigid about any particular set of guidelines. – Felix Jan 4 at 10:04
0

Whatever is calling your service will be a program

In the program the logic for calling your service will be seperated into a client library

The client library will expose methods for calling your end point that don't have to match the endpoint format.

ie:

client.getInvoice(id, targetservice)

client.serviceA.getInvoiceById(id)

client.getInvoice.FromService(targetservice)[id]

Make your service as performant as possible, regardless of the urls and paths. Adjust your client library for usability.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.