What's are they and how are they used?
For further actions, you may consider blocking this person and/or reporting abuse
What's are they and how are they used?
For further actions, you may consider blocking this person and/or reporting abuse
Mike Young -
Mike Young -
Daniel Kukula -
Arindam Pratap -
Top comments (5)
Classic RPC allows the client to use remote code as though it were local code.
Theoretically, the client does not need to know whether the code runs locally or the request is transmitted and executed on the server. Although it may be unwise to actually ignore that consideration.
Thanks Kasey. So say I wrap a simple HTTP request library to hit an API somewher, so that it looks like I'm just running local functions or methods in my program, does that count as an RPC?
It could be. Traditionally, RPC means that when I call a procedure on the client, it is a stand-in for the same method on a remote machine. When I call
Api.Something()
on the client, thenSomething()
is to be called on the server. (I should have made that more clear in my original answer.) HTTP could be used as the transport mechanism, but (unlike REST) that is not emphasized.Imagine that you got a nice big train model table for your birthday. You love it but it hardly fits in your room. Imagine that you then receive a Carrera Digital 132 for Christmas which won't fit in your room separately from the train. Dad however figures out a way to have the two tracks cross each other, the train tracks even have their little boom barriers. As long as you use your toys separately, everything is okay, but you really like your trains and want to keep them running. However this means you can't race the cars without them potentially colliding with a train and ruining both forever.
Fortunately the train tracks come with a service called "Train service" running on a raspberry pi and providing various features. One of these features is very handy because it can stop the trains at the nearest empty station and make sure that the boom barriers are lifted. This is called the "StopAllTrains" procedure and it can be called by services of other toys remotely.
This is really cool because Dad is quite a geek so he can now also attach his ODROID-XU4 to create a new "Racing" service for the glowing tracks.
When everything is set up, you can just push a button on the Racing control device. The Racing service will pick this up and call the StopAllTrains procedure of the Train service. Then the trains will get safely stopped in the next station and the barriers will get lifted as well. When this is all done the Racing service will be notified that it is now safe to start the race. The race then starts and no toy gets broken.
Optionally you can also make this smarter by telling the Train service how long the race will take place. This might be different based on the length of the racing track and the number of curves in it but the Track service knows how to calculate it. When the Racing service tells the Train service that the race will take 1 minute than the trains can automatically leave their stations after stopping for 60 seconds.
Thanks for the reply. How are RPC's different than just remotley hitting an API endpoint that triggers some code to run on that server?