lidavidm commented on a change in pull request #153:
URL: https://github.com/apache/arrow-cookbook/pull/153#discussion_r814355176
##########
File path: cpp/source/flight.rst
##########
@@ -83,3 +83,72 @@ Finally, we'll stop our server:
.. recipe:: ../code/flight.cc ParquetStorageService::StopServer
:dedent: 2
+
+
+Setting gRPC client options
+===========================
+
+Options for gRPC clients can be passed in using the ``generic_options`` field
of
+:cpp:class:`arrow::flight::FlightClientOptions`. There is a list of available
+client options in the `gRPC API documentation
<https://grpc.github.io/grpc/cpp/group__grpc__arg__keys.html>`_.
+
+For example, you can change the maximum message length sent with:
+
+.. recipe:: ../code/flight.cc TestClientOptions::Connect
+ :dedent: 2
+
+
+Flight Service with other gRPC endpoints
+========================================
+
+If you are using the gRPC backend, you can add other gRPC endpoints to the
+Flight server. While Flight clients won't recognize these endpoints, general
+gRPC clients will be able to.
+
+.. note::
+ If statically linking Arrow Flight, Protobuf and gRPC must also be
statically
+ linked, and the same goes for dynamic linking. Read more at
+ https://arrow.apache.org/docs/cpp/build_system.html#a-note-on-linking
+
+Creating the server
+-------------------
+
+To create a gRPC service, first define a service using protobuf.
+
+.. literalinclude:: ../code/protos/helloworld.proto
+ :language: protobuf
+ :linenos:
+ :start-at: syntax = "proto3";
+ :caption: Hello world protobuf specification
+
+Next, you'll need to compile that to provide the protobuf and gRPC generated
+files. See gRPC's `generating client and server code
+<https://grpc.io/docs/languages/cpp/basics/#generating-client-and-server-code>`_
+docs for details.
+
+Then write an implementation for the gRPC service:
+
+.. literalinclude:: ../code/flight.cc
+ :language: cpp
+ :linenos:
+ :start-at: class HelloWorldServiceImpl
+ :end-at: }; // end HelloWorldServiceImpl
+ :caption: Hello world gRPC service implementation
+
+Finally, use the ``builder_hook`` hook on
:cpp:class:`arrow::flight::FlightServerOptions`
+to register the additional gRPC service.
+
+.. recipe:: ../code/flight.cc CustomGrpcImpl::StartServer
+ :dedent: 2
+
+Creating the client
+-------------------
+
+The Flight client implementation doesn't know about any custom gRPC services,
+so to call them you'll need to create a normal gRPC client. For the Hello World
+service, we use the HelloWorldService stub, which is provided by the compiled
+protobuf definition. Note that we can connect to either of the two ports
+exposed.
Review comment:
Now it's only one port :) Though we could call out that both services
are on the same port.
##########
File path: cpp/source/flight.rst
##########
@@ -83,3 +83,72 @@ Finally, we'll stop our server:
.. recipe:: ../code/flight.cc ParquetStorageService::StopServer
:dedent: 2
+
+
+Setting gRPC client options
+===========================
+
+Options for gRPC clients can be passed in using the ``generic_options`` field
of
+:cpp:class:`arrow::flight::FlightClientOptions`. There is a list of available
+client options in the `gRPC API documentation
<https://grpc.github.io/grpc/cpp/group__grpc__arg__keys.html>`_.
+
+For example, you can change the maximum message length sent with:
+
+.. recipe:: ../code/flight.cc TestClientOptions::Connect
+ :dedent: 2
+
+
+Flight Service with other gRPC endpoints
+========================================
+
+If you are using the gRPC backend, you can add other gRPC endpoints to the
+Flight server. While Flight clients won't recognize these endpoints, general
+gRPC clients will be able to.
+
+.. note::
+ If statically linking Arrow Flight, Protobuf and gRPC must also be
statically
+ linked, and the same goes for dynamic linking. Read more at
+ https://arrow.apache.org/docs/cpp/build_system.html#a-note-on-linking
+
+Creating the server
+-------------------
+
+To create a gRPC service, first define a service using protobuf.
+
+.. literalinclude:: ../code/protos/helloworld.proto
+ :language: protobuf
+ :linenos:
+ :start-at: syntax = "proto3";
+ :caption: Hello world protobuf specification
+
+Next, you'll need to compile that to provide the protobuf and gRPC generated
+files. See gRPC's `generating client and server code
+<https://grpc.io/docs/languages/cpp/basics/#generating-client-and-server-code>`_
+docs for details.
+
+Then write an implementation for the gRPC service:
+
+.. literalinclude:: ../code/flight.cc
+ :language: cpp
+ :linenos:
+ :start-at: class HelloWorldServiceImpl
+ :end-at: }; // end HelloWorldServiceImpl
+ :caption: Hello world gRPC service implementation
+
+Finally, use the ``builder_hook`` hook on
:cpp:class:`arrow::flight::FlightServerOptions`
+to register the additional gRPC service.
+
+.. recipe:: ../code/flight.cc CustomGrpcImpl::StartServer
+ :dedent: 2
+
+Creating the client
+-------------------
+
+The Flight client implementation doesn't know about any custom gRPC services,
+so to call them you'll need to create a normal gRPC client. For the Hello World
+service, we use the HelloWorldService stub, which is provided by the compiled
+protobuf definition. Note that we can connect to either of the two ports
Review comment:
Protobuf?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]