the gRPC version: v1.0.1-GA
The who gRPC code base have several components
- server
- transport
- clientconn
- rpc_utils
- metadata
- credentials
- codes
- call
Server
the server is mainly contain the gRPC server struct, service struct and main flow functions to handle grpc requests.
// Server is a gRPC server to serve RPC requests.
type Server struct {
opts options
mu sync.Mutex // guards following
lis map[net.Listener]bool
conns map[io.Closer]bool
drain bool
// A CondVar to let GracefulStop() blocks until all the pending RPCs are finished
// and all the transport goes away.
cv *sync.Cond
m map[string]*service // service name -> service info
events trace.EventLog
}
Transport
the transport package mainly contain the underlying communication mechanism(HTTP2 protocol
) implementation and interface(ServerTransport, ClientTransport
) for the server and client.
ClientConn
clientconn is mainly about connect and manage network connection to a gRPC server.
rpc_util
rpc_util mainly contains marshal, unmarshal, encode, receive, decode util function of rpc messages.
metadata
metadata package is about encode and decode metadata to and from context when sending or received grpc request.
credentials
credentials implements various credentials supported by gRPC library, which encapsulate all the state needed by a client to authenticate with a server and make various assertions.
codes
define the error codes used by gRPC server
call
call.go
contains the functions called by the IDL generated code(xxx.pb.go), which used to send grpc request and receive grpc response message.