consul/contributing/rpc
Daniel Nephin a1fbd2d007 docs: move the remaining content from INTERNALS.md
Into the appropriate section of the docs.
2021-08-20 16:39:35 -04:00
..
streaming contributing: start an outline for more docs 2021-07-05 18:25:00 -04:00
README.md docs: move the remaining content from INTERNALS.md 2021-08-20 16:39:35 -04:00
routing.mmd contrib: add first draft of RPC docs 2021-07-07 13:38:10 -04:00
routing.svg contrib: add first draft of RPC docs 2021-07-07 13:38:10 -04:00

README.md

RPC

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.

RPC Routing

source

The main entrypoint to RPC routing is handleConn in 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
  • agent/structs - contains definitions of all the internal RPC protocol request and response structures.

RPC connections and load balancing

This section is a work in progress, it will eventually cover topics like:

Routing RPC request to Consul servers and for connection pooling.