From da67bdcc31efa65b73b8507c1a1dd57891321985 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 5 Jul 2021 18:13:25 -0400 Subject: [PATCH] contrib: add first draft of RPC docs --- contributing/rpc/README.md | 50 +++++++++++++++++-- .../rpc/{rpc-routing.mmd => routing.mmd} | 0 contributing/rpc/routing.svg | 1 + contributing/rpc/rpc-routing.svg | 1 - 4 files changed, 48 insertions(+), 4 deletions(-) rename contributing/rpc/{rpc-routing.mmd => routing.mmd} (100%) create mode 100644 contributing/rpc/routing.svg delete mode 100644 contributing/rpc/rpc-routing.svg diff --git a/contributing/rpc/README.md b/contributing/rpc/README.md index a177f7f912..4732e58d61 100644 --- a/contributing/rpc/README.md +++ b/contributing/rpc/README.md @@ -1,6 +1,50 @@ # RPC -- net/rpc - (in the stdlib) -- [Streaming](./streaming) -- routing of "RPC" requests +This section is a work in progress. +The RPC subsystem is exclusicely in Server Agents. It is comprised of two main components: + +1. the "RPC Server" (for lack of a better term) handles multiplexing of many different + requests on a single TCP port. +2. RPC endpoints handle RPC requests and return responses. + +The RPC subsystems handles requests from: + +1. Client Agents in the local DC +2. (if the server is a leader) other Server Agents in the local DC +3. Server Agents in other Datacenters +4. in-process requests from other components running in the same process (ex: the HTTP API + or DNS interface). + +## Routing + +The "RPC Server" accepts requests to the [server port] and routes the requests based on +configuration of the Server and the the first byte in the request. The diagram below shows +all the possible routing flows. + +[server port]: https://www.consul.io/docs/agent/options#server_rpc_port + +![RPC Routing](./routing.svg) + +[source](./routing.mmd) + +The main entrypoint to RPC routing is `handleConn` in [agent/consul/rpc.go]. + +[agent/consul/rpc.go]: https://github.com/hashicorp/consul/blob/main/agent/consul/rpc.go + + +## RPC Endpoints + +This section is a work in progress, it will eventually cover topics like: + +- net/rpc - (in the stdlib) +- new grpc endpoints +- [Streaming](./streaming) + + +## RPC connections and load balancing + +This section is a work in progress, it will eventually cover topics like: + +- agent/router +- agent/pool diff --git a/contributing/rpc/rpc-routing.mmd b/contributing/rpc/routing.mmd similarity index 100% rename from contributing/rpc/rpc-routing.mmd rename to contributing/rpc/routing.mmd diff --git a/contributing/rpc/routing.svg b/contributing/rpc/routing.svg new file mode 100644 index 0000000000..0a63bd5d77 --- /dev/null +++ b/contributing/rpc/routing.svg @@ -0,0 +1 @@ +
RPCConsul
RPCRaft
RPCTLS
RPCMultiplexV2
RPCSnapshot
RPCTLSInsecure
RPCGossip
PeekForTLS
ALPN_RPCConsul
ALPN_RPCRaft
ALPN_RPCMultiplexV2
ALPN_RPCSnapshot
ALPN_RPCGRPC
ALPN_WANGossipPacket
ALPN_WANGossipStream
ALPN_RPCGossip
RPCGossip
RPCGRPC
handleConn
handleConsulConn
raftLayer
handleMultiplexV2
handleSnapshotConn
handleInsecureConn
handleGossipConn
RPCServer
handleNativeTLS
grpcHandler
handleWANGossipPacket
handleWANGossipStream
\ No newline at end of file diff --git a/contributing/rpc/rpc-routing.svg b/contributing/rpc/rpc-routing.svg deleted file mode 100644 index 21c4f913dc..0000000000 --- a/contributing/rpc/rpc-routing.svg +++ /dev/null @@ -1 +0,0 @@ -
RPCConsul
RPCRaft
RPCTLS
RPCMultiplexV2
RPCSnapshot
RPCTLSInsecure
RPCGossip
PeekForTLS
ALPN_RPCConsul
ALPN_RPCRaft
ALPN_RPCMultiplexV2
ALPN_RPCSnapshot
ALPN_RPCGRPC
ALPN_WANGossipPacket
ALPN_WANGossipStream
ALPN_RPCGossip
RPCGossip
RPCGRPC
handleConn
handleConsulConn
raftLayer
handleMultiplexV2
handleSnapshotConn
handleInsecureConn
handleGossipConn
RPCServer
handleNativeTLS
grpcHandler
handleWANGossipPacket
handleWANGossipStream
\ No newline at end of file