Why is the term stub used for RPC?
Asked Answered
M

1

9

Wikipedia says

A stub in distributed computing is a piece of code that converts parameters passed between client and server during a remote procedure call (RPC)

How does the original meaning of the word stub relate to its function in RPC?

Mohl answered 15/10, 2021 at 23:18 Comment(1)
In code, the word "stub" is often used to mean something that stands in place of the real or final thing. In the context of RPC the client stub stands in place of the target function that will ultimately be executed, while allowing the client to call the stub as if it was was the target implementation. At least that is how I would think about it.Shererd
P
16

A stub is a short part of a whole, like a ticket stub or the stub remnant of a used pencil. Equivalently it is something "cut short." In computing, the stub looks like the method, but doesn't have the method's logic. The method's processing is "cut short" in that much of it is missing. The stub term is also used for "test stubs" (a.k.a. mocks) and "method stubs". Some people may call them "stand ins" instead.

Test stubs are commonly seen, but you may not be as familiar with method stubs. Method stubs are barely-implemented methods that have the proper arguments and return the right type of value but don't have the appropriate processing. For example, a stub for a random() function could always return 4. They are common in emulators and when initially implementing a system.

For RPCs, the stub converts its methods, request types, and response types into the forms used by the RPC system. But the actual processing of the RPC is done remotely. The stub is essentially just a usability feature to provide the appearance the remote method is present locally.

Phytopathology answered 15/10, 2021 at 23:34 Comment(4)
Thanks! The (trivial)question is actually more about why it is named stub. e.g., why don't we name it something like "RPCWrapper" or "RPCAdaptor"?Mohl
Ah, okay. I expanded the answer.Phytopathology
It makes a lot of sense to me now, thank you so much!Mohl
Good answer. The W3 article also explains w3.org/History/1992/nfs_dxcern_mirror/rpc/doc/Introduction/…Clyburn

© 2022 - 2024 — McMap. All rights reserved.