Remote Procedure Call (RPC) frameworks In classical RPC systems, the client uses a
client-side stub (proxy) which packages the parameters of a call (
marshalling) and sends them over the network. On the server side, a
server-side stub (skeleton) unpacks the request (
unmarshalling), invokes the procedure, and then sends the result back. This mechanism allows the client to call remote functions as if they were local.
Automatic stub generation (IDL-based) Many RPC implementations use an
Interface Definition Language (IDL) to describe services. The IDL
compiler automatically generates both client and server stubs, including all necessary marshalling and unmarshalling operations.
gRPC In
gRPC, the client holds a local object called a
stub, which implements the same methods as the remote service. When a method is invoked, the stub serializes the request into Protobuf, sends it to the server, and returns the structured response, making remote calls transparent to the client.
Java RMI In
Java Remote Method Invocation (RMI), stub classes are generated using the rmic compiler. The client interacts with these stub classes to invoke methods on remote objects as if they were local, while the underlying stub manages the network communication.
Distributed object systems In
distributed object communication (such as CORBA), stubs act as proxies for clients while server skeletons handle incoming requests. They are responsible for network communication, parameter marshalling, and method invocation. == Steps to writing tests with stubs ==