In distributed computing, a RPC is when a computer program causes a procedure (subroutine) to execute in a different address space, which is coded as if it were a normal local procedure call, without the programmer explicitly coding the details for the remote interaction.
An important difference between remote procedure calls and local calls is that remote calls can fail because of unpredictable network problems. Also, callers generally must deal with such failures without knowing whether the remote procedure was actually invoked. Idempotent procedures (those that have no additional effects if called more than once) are easily handled, but enough difficulties remain that code to call remote procedure is often confined to carefully written low-level subsystems.
Sequence of events
- The client calls the client stub. The call is a local procedure call, with parameters pushed on to the stack in the normal way.
- The client stub packs the parameters into a message and makes a system call to send the message. Packing the parameters is called marshalling.
- The client’s local operating system sends a message from the client machien to the server machine.
- The local operating system on the server machine passes the incoming packets to the server stub.
- The server stub unpacks the parameters from the message. Unpacking the parameters is called unmarshalling.
- Finally, the server stub calls the server procedure. The reply traces the same steps in the reverse direction.
https://golang.org/pkg/net/rpc/
brew install grpc protobuf
go get -u github.com/golang/protobuf/protoc-gen-go
export PATH=$PATH:$HOME/go/bin, in order to add the GOPATH and export PATH=$PATH:/usr/local/go/bin, in order to add GOROOT
protoc –go_out=. *.proto