Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is RPC disguised as REST a bad idea?

Our whole system is being designed around REST and are now considering how processes which are quite clearly RPC in intent can be mapped to RESTful resources without using verbs in the URL. Our remote procedure call is used to rebuild our search index when a content listing has been modified elsewhere.

What we are thinking about doing is this:

POST /index_updates

<indexUpdate><contentId>123</contentId></indexUpdate>

Nothing wrong with that in itself, but the smell is this resource which has been created does not return the URL of the newly created resource e.g. /index_updates/1234 which we can then access with a GET.

The indexing engine we are using does have a log mechanism, so in theory we could return a URL to a index_update resource so as to allow a GET to retrieve the resource, but to be honest we're not interested in the resource as this is nothing more than an RPC in disguise.

So my question is whether RESTfulness is expressed in structure or intent. I feel the structure of what I have outlined is restful, but the intent is not.

Does anyone have an comments or advice?

Thanks,

Chris

like image 284
ChrisInCambo Avatar asked Dec 22 '08 09:12

ChrisInCambo


People also ask

Should I use RPC or REST?

The most fundamental difference between RPC and REST is that RPC was designed for actions, while REST is resource-centric. RPC executes procedures and commands with ease. Alternatively, REST is ideal for domain modeling and handling large quantities of data.

When should RPC be used?

RPC is very well suited for a client-server interaction in which the flow of control lingers between the two. The client and server do not both execute at the same time instead the thread of execution jumps from one to another.

Is REST a remote procedure call?

Remote-Procedure-Call (RPC), for example, is one style of creating web APIs. Representational State Transfer (REST), on the other hand, is another approach. Each style has a separate implementation. The confusion stems from the fact both styles communicate over HTTP.

Is RPC the same as API?

RPC is the earliest, simplest form of API interaction. It is about executing a block of code on another server, and when implemented in HTTP or AMQP it can become a Web API.


1 Answers

Use the right tool for the job. In this case, it definitely seems like the right tool is a pure remote procedure call, and there's no reason to pretend it's REST.

like image 170
Matthew Flaschen Avatar answered Oct 15 '22 03:10

Matthew Flaschen