NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
serve_options.h
1// neograph::grpc — how a built-in server runs.
2//
3// run_server, run_tool_server and run_checkpoint_server each start one gRPC
4// server for one NeoGraph service. Without ServeOptions::credentials the
5// server is insecure (no TLS, no authentication), the way it always was;
6// ServeOptions::credentials takes the caller's server credentials, TLS and
7// mutual TLS among them. Every built-in server also answers the standard
8// health service, grpc.health.v1.Health: SERVING for the server ("") and for
9// its service ("neograph.v1.GraphService", "neograph.v1.ToolService" or
10// "neograph.v1.CheckpointService") while it accepts calls, NOT_SERVING once
11// it begins to stop. The overloads that take ServeOptions can also be
12// stopped and report the bound port. For authentication interceptors or more
13// services on one port, register make_graph_service(), make_tool_service()
14// or make_checkpoint_service() with your own grpc::ServerBuilder instead.
15//
16// Server reflection is the host's choice: link gRPC::grpc++_reflection and
17// call grpc::reflection::InitProtoReflectionServerBuilderPlugin() once before
18// the servers start. gRPC then adds it to every server of the process, the
19// built-in ones included.
20//
21// Opt-in (NEOGRAPH_BUILD_GRPC). Whole header behind NEOGRAPH_HAVE_GRPC.
22
23#pragma once
24
25#ifdef NEOGRAPH_HAVE_GRPC
26
27#include <chrono>
28#include <cstddef>
29#include <functional>
30#include <memory>
31#include <stop_token>
32
33// Declared, not included: a program that only starts a server with the
34// defaults needs no gRPC header beyond the ones of the service it serves.
35namespace grpc {
36class ServerCredentials;
37}
38
39namespace neograph::grpc {
40
41struct ServeOptions {
46 std::stop_token stop;
48 std::chrono::milliseconds shutdown_grace{std::chrono::seconds(5)};
52 std::function<void(int port)> on_serving;
61 std::shared_ptr<::grpc::ServerCredentials> credentials;
66 std::size_t max_receive_message_bytes = 0;
71 std::size_t max_send_message_bytes = 0;
72};
73
74} // namespace neograph::grpc
75
76#endif // NEOGRAPH_HAVE_GRPC