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

  1. The client calls the client stub. The call is a local procedure call, with parameters pushed on to the stack in the normal way.
  2. The client stub packs the parameters into a message and makes a system call to send the message. Packing the parameters is called marshalling.
  3. The client’s local operating system sends a message from the client machien to the server machine.
  4. The local operating system on the server machine passes the incoming packets to the server stub.
  5. The server stub unpacks the parameters from the message. Unpacking the parameters is called unmarshalling.
  6. 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