Files
Craig Tiller 339906443b [clang-format] Match include file ordering to internal clang-format (#40905)
gRPC is currently getting formatted with two different clang-format implementations, and due to some weirdness they have different include file orderings. This change introduces clang-format configuration to ensure that the two systems align - it's *highly* expected that this will need some maintenance going forward as the two systems evolve.

Closes #40905

PiperOrigin-RevId: 819606209
2025-10-15 00:24:11 -07:00
..
2025-03-27 18:49:43 -07:00
2024-10-15 13:43:34 -07:00

gRPC C++ Interceptors Example

The C++ Interceptors example shows how interceptors might be used with a simple key-value store. Note that the C++ Interception API is still experimental and subject to change.

Key Value Store

The key-value store service is defined in keyvaluestore.proto.It has a simple bidi streaming RPC where the request messages contain a key and the response messages contain a value.

The example shows a very naive CachingInterceptor added on the client channel that caches the key-value pairs that it sees. If the client looks up a key present in the cache, the interceptor responds with its saved value and the server doesn't see the request for that key.

On the server-side, a very simple logging interceptor is added that simply logs to stdout whenever a new RPC is received.

Running the example

To run the server -

$ tools/bazel run examples/cpp/interceptors:keyvaluestore_server

To run the client (on a different terminal) -

$ tools/bazel run examples/cpp/interceptors:keyvaluestore_client