xref: /aosp_15_r20/external/pigweed/pw_grpc/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_grpc:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker=======
4*61c4878aSAndroid Build Coastguard Workerpw_grpc
5*61c4878aSAndroid Build Coastguard Worker=======
6*61c4878aSAndroid Build Coastguard Worker.. pigweed-module::
7*61c4878aSAndroid Build Coastguard Worker   :name: pw_grpc
8*61c4878aSAndroid Build Coastguard Worker
9*61c4878aSAndroid Build Coastguard Worker``pw_grpc`` is an implementation of the gRPC over HTTP2 protocol that utilizes
10*61c4878aSAndroid Build Coastguard Worker``pw_rpc`` for code generation and service hosting. It provides classes that map
11*61c4878aSAndroid Build Coastguard Workerbetween pw_rpc packets and gRPC HTTP2 frames, allowing pw_rpc services to be
12*61c4878aSAndroid Build Coastguard Workerexposed as gRPC services.
13*61c4878aSAndroid Build Coastguard Worker
14*61c4878aSAndroid Build Coastguard Worker--------
15*61c4878aSAndroid Build Coastguard WorkerOverview
16*61c4878aSAndroid Build Coastguard Worker--------
17*61c4878aSAndroid Build Coastguard WorkerThe ``Connection`` class implements the gRPC HTTP2 protocol on top of a socket
18*61c4878aSAndroid Build Coastguard Workerlike stream. Create a new instance every time a new connection is established.
19*61c4878aSAndroid Build Coastguard WorkerIt will notify when new RPC calls are started, data is received, the call is
20*61c4878aSAndroid Build Coastguard Workercancelled, and when the connection stream should be closed.
21*61c4878aSAndroid Build Coastguard Worker
22*61c4878aSAndroid Build Coastguard WorkerThe ``PwRpcHandler`` class is what maps gRPC events provided by ``Connection``
23*61c4878aSAndroid Build Coastguard Workerinstances to ``pw_rpc`` packets. It takes a ``pw::rpc::RpcPacketProcessor``
24*61c4878aSAndroid Build Coastguard Workerto forward packets to.
25*61c4878aSAndroid Build Coastguard Worker
26*61c4878aSAndroid Build Coastguard WorkerThe ``GrpcChannelOutput`` class is what handles mapping outgoing ``pw_rpc``
27*61c4878aSAndroid Build Coastguard Workerpackets back to the ``Connection`` send methods, which will translate to gRPC
28*61c4878aSAndroid Build Coastguard Workerresponses.
29*61c4878aSAndroid Build Coastguard Worker
30*61c4878aSAndroid Build Coastguard WorkerRefer to the ``test_pw_rpc_server.cc`` file for detailed usage example of how to
31*61c4878aSAndroid Build Coastguard Workerintegrate into a ``pw_rpc`` network.
32