mirror of https://github.com/grpc/grpc-ios.git
Compare commits
34 Commits
Author | SHA1 | Date |
---|---|---|
|
52d0c6c326 | |
|
d88573fd5f | |
|
e584a88115 | |
|
96ddc18603 | |
|
fcb8b99697 | |
|
9849f527f0 | |
|
30bd3c9d49 | |
|
78593d170e | |
|
c92e41c10b | |
|
b641ac3789 | |
|
5c9cda2cf6 | |
|
6797fe4c02 | |
|
263faa1c99 | |
|
474418cd86 | |
|
14c4d3795c | |
|
76d3d2f8d7 | |
|
53fa90a969 | |
|
32c56c60fc | |
|
c7cb8a8a05 | |
|
2453c26211 | |
|
b69ba65eac | |
|
1a8feab3fb | |
|
a108b20993 | |
|
dfd58160de | |
|
bc0d47377a | |
|
a583a741a8 | |
|
5f768c6c2e | |
|
ad9f5fd929 | |
|
6ae523d87a | |
|
a5274614c4 | |
|
66e013d603 | |
|
585d634f4a | |
|
bb29a1f5b9 | |
|
cf716d724f |
|
@ -15,7 +15,9 @@ jobs:
|
|||
run: scripts/prepare_env.sh
|
||||
|
||||
- name: Shallow source source
|
||||
run: scripts/sync_grpc_src_shallow.sh
|
||||
run: |
|
||||
source .venv/bin/activate
|
||||
scripts/sync_grpc_src_shallow.sh
|
||||
|
||||
- name: Collect revision hash
|
||||
run: |
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# This is a basic workflow that is manually triggered
|
||||
|
||||
name: Manual push a pod
|
||||
|
||||
# Controls when the action will run. Workflow runs when manually triggered using the UI
|
||||
# or API.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Release tag'
|
||||
default: ''
|
||||
required: true
|
||||
type: string
|
||||
pod:
|
||||
description: 'Pod name without .podspec'
|
||||
default: 'gRPC'
|
||||
required: true
|
||||
type: string
|
||||
env:
|
||||
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
|
||||
TAG: ${{ inputs.tag }}
|
||||
|
||||
jobs:
|
||||
release-cocoapod:
|
||||
runs-on: macos-14
|
||||
steps:
|
||||
- name: Repo checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: refs/tags/${{ inputs.tag }}
|
||||
|
||||
- name: Prepare environment
|
||||
run: scripts/prepare_env.sh
|
||||
|
||||
- name: Pod release
|
||||
run: scripts/release_cocoapod.sh ${{ inputs.pod }}.podspec
|
||||
|
||||
- name: Wait for pod avaialble
|
||||
run: |
|
||||
version=${TAG#v}
|
||||
timeout 1h scripts/wait_for_pod_release.sh ${{ inputs.pod }} $version
|
|
@ -24,7 +24,7 @@ let package = Package(
|
|||
],
|
||||
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20240116.1"..<"0.20240117.0"),
|
||||
.package(url: "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20250127.0"..<"0.20250128.0"),
|
||||
.package(url: "https://github.com/firebase/boringssl-SwiftPM.git", "0.32.0"..<"0.33.0"),
|
||||
],
|
||||
|
||||
|
@ -41,14 +41,13 @@ let package = Package(
|
|||
"src/cpp/",
|
||||
"third_party/upb/upb/port/def.inc",
|
||||
"third_party/upb/upb/port/undef.inc",
|
||||
"third_party/utf8_range/utf8_range_sse.inc",
|
||||
"third_party/utf8_range/utf8_range_neon.inc",
|
||||
"third_party/re2/LICENSE",
|
||||
"third_party/utf8_range/LICENSE",
|
||||
"third_party/xxhash/LICENSE",
|
||||
"third_party/zlib/LICENSE",
|
||||
"tests",
|
||||
"include/grpc/grpc_cronet.h",
|
||||
"src/core/ext/transport/cronet/",
|
||||
"third_party/objective_c/Cronet/bidirectional_stream_c.h",
|
||||
],
|
||||
|
||||
sources: [
|
||||
|
@ -66,6 +65,7 @@ let package = Package(
|
|||
.headerSearchPath("third_party/upb/"),
|
||||
.headerSearchPath("third_party/utf8_range/"),
|
||||
.headerSearchPath("third_party/xxhash/"),
|
||||
.headerSearchPath("third_party/address_sorting/include/"),
|
||||
.headerSearchPath("src/core/ext/upb-gen/"),
|
||||
.headerSearchPath("src/core/ext/upbdefs-gen/"),
|
||||
.define("GRPC_ARES", to: "0"),
|
||||
|
@ -84,8 +84,8 @@ let package = Package(
|
|||
path: basePath,
|
||||
exclude: [
|
||||
"tests",
|
||||
"include/grpcpp/security/cronet_credentials.h",
|
||||
"src/cpp/client/cronet_credentials.cc",
|
||||
"include/grpcpp/ports_undef.inc",
|
||||
"include/grpcpp/ports_def.inc",
|
||||
],
|
||||
sources: [
|
||||
"src/cpp/",
|
||||
|
@ -110,5 +110,5 @@ let package = Package(
|
|||
),
|
||||
],
|
||||
cLanguageStandard: .gnu11,
|
||||
cxxLanguageStandard: .cxx14
|
||||
cxxLanguageStandard: .cxx17
|
||||
)
|
||||
|
|
913
gRPC-C++.podspec
913
gRPC-C++.podspec
File diff suppressed because it is too large
Load Diff
1216
gRPC-Core.podspec
1216
gRPC-Core.podspec
File diff suppressed because it is too large
Load Diff
|
@ -21,7 +21,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-ProtoRPC'
|
||||
version = '1.65.0-dev'
|
||||
version = '1.73.1'
|
||||
s.version = version
|
||||
s.summary = 'RPC library for Protocol Buffers, based on gRPC'
|
||||
s.homepage = 'https://grpc.io'
|
||||
|
@ -33,9 +33,9 @@ Pod::Spec.new do |s|
|
|||
:tag => "v#{version}",
|
||||
}
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
|
||||
|
@ -55,7 +55,7 @@ Pod::Spec.new do |s|
|
|||
ss.header_mappings_dir = "src/objective-c/ProtoRPC"
|
||||
ss.dependency "#{s.name}/Legacy-Header", version
|
||||
ss.dependency 'gRPC/Interface', version
|
||||
ss.dependency 'Protobuf', '~> 3.0'
|
||||
ss.dependency 'Protobuf', '~> 4.0'
|
||||
|
||||
ss.source_files = "src/objective-c/ProtoRPC/ProtoMethod.{h,m}",
|
||||
"src/objective-c/ProtoRPC/ProtoRPC.{h,m}",
|
||||
|
@ -68,7 +68,7 @@ Pod::Spec.new do |s|
|
|||
ss.dependency "#{s.name}/Legacy-Header", version
|
||||
ss.dependency 'gRPC/GRPCCore', version
|
||||
ss.dependency 'gRPC-RxLibrary', version
|
||||
ss.dependency 'Protobuf', '~> 3.0'
|
||||
ss.dependency 'Protobuf', '~> 4.0'
|
||||
|
||||
ss.source_files = "src/objective-c/ProtoRPC/ProtoRPCLegacy.m",
|
||||
"src/objective-c/ProtoRPC/ProtoServiceLegacy.m"
|
||||
|
@ -85,6 +85,6 @@ Pod::Spec.new do |s|
|
|||
# This is needed by all pods that depend on gRPC-RxLibrary:
|
||||
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
|
||||
'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
|
||||
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
|
||||
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
||||
}
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-RxLibrary'
|
||||
version = '1.65.0-dev'
|
||||
version = '1.73.1'
|
||||
s.version = version
|
||||
s.summary = 'Reactive Extensions library for iOS/OSX.'
|
||||
s.homepage = 'https://grpc.io'
|
||||
|
@ -33,9 +33,9 @@ Pod::Spec.new do |s|
|
|||
:tag => "v#{version}",
|
||||
}
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
|
||||
|
@ -67,6 +67,6 @@ Pod::Spec.new do |s|
|
|||
|
||||
s.pod_target_xcconfig = {
|
||||
'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
|
||||
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
|
||||
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
||||
}
|
||||
end
|
||||
|
|
59
gRPC.podspec
59
gRPC.podspec
|
@ -20,7 +20,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC'
|
||||
version = '1.65.0-dev'
|
||||
version = '1.73.1'
|
||||
s.version = version
|
||||
s.summary = 'gRPC client library for iOS/OSX'
|
||||
s.homepage = 'https://grpc.io'
|
||||
|
@ -42,12 +42,12 @@ Pod::Spec.new do |s|
|
|||
# This is needed by all pods that depend on gRPC-RxLibrary:
|
||||
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
|
||||
'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
|
||||
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
|
||||
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
||||
}
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
|
||||
|
@ -64,7 +64,6 @@ Pod::Spec.new do |s|
|
|||
|
||||
ss.public_header_files = "src/objective-c/GRPCClient/GRPCCall+ChannelArg.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+Cronet.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+OAuth2.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+Tests.h",
|
||||
"src/objective-c/GRPCClient/GRPCCallLegacy.h",
|
||||
|
@ -72,7 +71,6 @@ Pod::Spec.new do |s|
|
|||
|
||||
ss.source_files = "src/objective-c/GRPCClient/GRPCCall+ChannelArg.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+Cronet.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+OAuth2.h",
|
||||
"src/objective-c/GRPCClient/GRPCCall+Tests.h",
|
||||
"src/objective-c/GRPCClient/GRPCCallLegacy.h",
|
||||
|
@ -80,9 +78,9 @@ Pod::Spec.new do |s|
|
|||
"src/objective-c/GRPCClient/GRPCTypes.mm"
|
||||
ss.dependency "gRPC-RxLibrary/Interface", version
|
||||
ss.dependency "#{s.name}/Privacy", version
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
end
|
||||
|
@ -116,9 +114,9 @@ Pod::Spec.new do |s|
|
|||
|
||||
ss.dependency "#{s.name}/Interface-Legacy", version
|
||||
ss.dependency "#{s.name}/Privacy", version
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
end
|
||||
|
@ -127,7 +125,6 @@ Pod::Spec.new do |s|
|
|||
ss.header_mappings_dir = 'src/objective-c/GRPCClient'
|
||||
|
||||
ss.public_header_files = 'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+Cronet.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+OAuth2.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+Tests.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+ChannelArg.h'
|
||||
|
@ -137,8 +134,6 @@ Pod::Spec.new do |s|
|
|||
'src/objective-c/GRPCClient/GRPCCall+ChannelArg.mm',
|
||||
'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.mm',
|
||||
'src/objective-c/GRPCClient/GRPCCall+Cronet.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+Cronet.mm',
|
||||
'src/objective-c/GRPCClient/GRPCCall+OAuth2.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+OAuth2.mm',
|
||||
'src/objective-c/GRPCClient/GRPCCall+Tests.h',
|
||||
|
@ -154,34 +149,20 @@ Pod::Spec.new do |s|
|
|||
ss.dependency 'gRPC-Core', version
|
||||
ss.dependency 'gRPC-RxLibrary', version
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
end
|
||||
|
||||
s.subspec 'GRPCCoreCronet' do |ss|
|
||||
ss.header_mappings_dir = 'src/objective-c/GRPCClient'
|
||||
|
||||
ss.source_files = 'src/objective-c/GRPCClient/GRPCCall+Cronet.h',
|
||||
'src/objective-c/GRPCClient/GRPCCall+Cronet.mm',
|
||||
'src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/*.{h,mm}'
|
||||
ss.dependency "#{s.name}/GRPCCore", version
|
||||
ss.dependency "#{s.name}/Privacy", version
|
||||
ss.dependency 'gRPC-Core/Cronet-Implementation', version
|
||||
ss.dependency 'CronetFramework'
|
||||
|
||||
ss.ios.deployment_target = '10.0'
|
||||
end
|
||||
|
||||
# CFStream is now default. Leaving this subspec only for compatibility purpose.
|
||||
s.subspec 'CFStream' do |ss|
|
||||
ss.dependency "#{s.name}/GRPCCore", version
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
end
|
||||
|
@ -192,9 +173,9 @@ Pod::Spec.new do |s|
|
|||
ss.source_files = 'src/objective-c/GRPCClient/internal_testing/*.{h,mm}'
|
||||
ss.header_mappings_dir = 'src/objective-c/GRPCClient'
|
||||
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.12'
|
||||
s.tvos.deployment_target = '12.0'
|
||||
s.ios.deployment_target = '15.0'
|
||||
s.osx.deployment_target = '11.0'
|
||||
s.tvos.deployment_target = '13.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
s.visionos.deployment_target = '1.0'
|
||||
end
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#ifndef GRPC_COMPRESSION_H
|
||||
#define GRPC_COMPRESSION_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <grpc/impl/compression_types.h> // IWYU pragma: export
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#ifndef GRPC_CREDENTIALS_H
|
||||
#define GRPC_CREDENTIALS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/grpc_security_constants.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -103,7 +102,7 @@ GRPCAPI grpc_call_credentials* grpc_sts_credentials_create(
|
|||
/** Context that can be used by metadata credentials plugin in order to create
|
||||
auth related metadata. */
|
||||
typedef struct {
|
||||
/** The fully qualifed service url. */
|
||||
/** The fully qualified service url. */
|
||||
const char* service_url;
|
||||
|
||||
/** The method name of the RPC being called (not fully qualified).
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_ENDPOINT_CONFIG_H
|
||||
#define GRPC_EVENT_ENGINE_ENDPOINT_CONFIG_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_event_engine {
|
||||
namespace experimental {
|
||||
|
@ -32,11 +32,11 @@ class EndpointConfig {
|
|||
public:
|
||||
virtual ~EndpointConfig() = default;
|
||||
// If the key points to an integer config, an integer value gets returned.
|
||||
// Otherwise it returns an absl::nullopt_t
|
||||
virtual absl::optional<int> GetInt(absl::string_view key) const = 0;
|
||||
// Otherwise it returns an std::nullopt_t
|
||||
virtual std::optional<int> GetInt(absl::string_view key) const = 0;
|
||||
// If the key points to an string config, an string value gets returned.
|
||||
// Otherwise it returns an absl::nullopt_t
|
||||
virtual absl::optional<absl::string_view> GetString(
|
||||
// Otherwise it returns an std::nullopt_t
|
||||
virtual std::optional<absl::string_view> GetString(
|
||||
absl::string_view key) const = 0;
|
||||
// If the key points to an void* config, a void* pointer value gets returned.
|
||||
// Otherwise it returns nullptr
|
||||
|
|
|
@ -14,20 +14,24 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_EVENT_ENGINE_H
|
||||
#define GRPC_EVENT_ENGINE_EVENT_ENGINE_H
|
||||
|
||||
#include <grpc/event_engine/endpoint_config.h>
|
||||
#include <grpc/event_engine/extensible.h>
|
||||
#include <grpc/event_engine/internal/write_event.h>
|
||||
#include <grpc/event_engine/memory_allocator.h>
|
||||
#include <grpc/event_engine/port.h>
|
||||
#include <grpc/event_engine/slice_buffer.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <bitset>
|
||||
#include <initializer_list>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
|
||||
#include <grpc/event_engine/endpoint_config.h>
|
||||
#include <grpc/event_engine/extensible.h>
|
||||
#include <grpc/event_engine/memory_allocator.h>
|
||||
#include <grpc/event_engine/port.h>
|
||||
#include <grpc/event_engine/slice_buffer.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
// TODO(vigneshbabu): Define the Endpoint::Write metrics collection system
|
||||
// TODO(hork): remove all references to the factory methods.
|
||||
namespace grpc_event_engine {
|
||||
namespace experimental {
|
||||
|
||||
|
@ -132,8 +136,6 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
struct TaskHandle {
|
||||
intptr_t keys[2];
|
||||
static const GRPC_DLL TaskHandle kInvalid;
|
||||
friend bool operator==(const TaskHandle& lhs, const TaskHandle& rhs);
|
||||
friend bool operator!=(const TaskHandle& lhs, const TaskHandle& rhs);
|
||||
};
|
||||
/// A handle to a cancellable connection attempt.
|
||||
///
|
||||
|
@ -141,10 +143,6 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
struct ConnectionHandle {
|
||||
intptr_t keys[2];
|
||||
static const GRPC_DLL ConnectionHandle kInvalid;
|
||||
friend bool operator==(const ConnectionHandle& lhs,
|
||||
const ConnectionHandle& rhs);
|
||||
friend bool operator!=(const ConnectionHandle& lhs,
|
||||
const ConnectionHandle& rhs);
|
||||
};
|
||||
/// Thin wrapper around a platform-specific sockaddr type. A sockaddr struct
|
||||
/// exists on all platforms that gRPC supports.
|
||||
|
@ -185,13 +183,26 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
/// EventEngine Endpoint Read API call.
|
||||
///
|
||||
/// Passed as argument to an Endpoint \a Read
|
||||
struct ReadArgs {
|
||||
class ReadArgs final {
|
||||
public:
|
||||
ReadArgs() = default;
|
||||
ReadArgs(const ReadArgs&) = delete;
|
||||
ReadArgs& operator=(const ReadArgs&) = delete;
|
||||
ReadArgs(ReadArgs&&) = default;
|
||||
ReadArgs& operator=(ReadArgs&&) = default;
|
||||
|
||||
// A suggestion to the endpoint implementation to read at-least the
|
||||
// specified number of bytes over the network connection before marking
|
||||
// the endpoint read operation as complete. gRPC may use this argument
|
||||
// to minimize the number of endpoint read API calls over the lifetime
|
||||
// of a connection.
|
||||
int64_t read_hint_bytes;
|
||||
void set_read_hint_bytes(int64_t read_hint_bytes) {
|
||||
read_hint_bytes_ = read_hint_bytes;
|
||||
}
|
||||
int64_t read_hint_bytes() const { return read_hint_bytes_; }
|
||||
|
||||
private:
|
||||
int64_t read_hint_bytes_ = 1;
|
||||
};
|
||||
/// Reads data from the Endpoint.
|
||||
///
|
||||
|
@ -200,9 +211,12 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
/// on_read callback is not executed. Otherwise it returns false and the \a
|
||||
/// on_read callback executes asynchronously when the read completes. The
|
||||
/// caller must ensure that the callback has access to the buffer when it
|
||||
/// executes. Ownership of the buffer is not transferred. Valid slices *may*
|
||||
/// be placed into the buffer even if the callback is invoked with a non-OK
|
||||
/// Status.
|
||||
/// executes. Ownership of the buffer is not transferred. Either an error is
|
||||
/// passed to the callback (like socket closed), or valid data is available
|
||||
/// in the buffer, but never both at the same time. Implementations that
|
||||
/// receive valid data must not throw that data away - that is, if valid
|
||||
/// data is received on the underlying endpoint, a callback will be made
|
||||
/// with that data available and an ok status.
|
||||
///
|
||||
/// There can be at most one outstanding read per Endpoint at any given
|
||||
/// time. An outstanding read is one in which the \a on_read callback has
|
||||
|
@ -214,20 +228,110 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
/// statuses to \a on_read. For example, callbacks might expect to receive
|
||||
/// CANCELLED on endpoint shutdown.
|
||||
virtual bool Read(absl::AnyInvocable<void(absl::Status)> on_read,
|
||||
SliceBuffer* buffer, const ReadArgs* args) = 0;
|
||||
SliceBuffer* buffer, ReadArgs args) = 0;
|
||||
//// The set of write events that can be reported by an Endpoint.
|
||||
using WriteEvent = ::grpc_event_engine::experimental::internal::WriteEvent;
|
||||
/// An output WriteMetric consists of a key and a value.
|
||||
/// The space of keys can be queried from the endpoint via the
|
||||
/// \a AllWriteMetrics, \a GetMetricName and \a GetMetricKey APIs.
|
||||
/// The value is an int64_t that is implementation-defined. Check with the
|
||||
/// endpoint implementation documentation for the semantics of each metric.
|
||||
struct WriteMetric {
|
||||
size_t key;
|
||||
int64_t value;
|
||||
};
|
||||
using WriteEventCallback = absl::AnyInvocable<void(
|
||||
WriteEvent, absl::Time, std::vector<WriteMetric>) const>;
|
||||
// A bitmask of the events that the caller is interested in.
|
||||
// Each bit corresponds to an entry in WriteEvent.
|
||||
using WriteEventSet = std::bitset<static_cast<int>(WriteEvent::kCount)>;
|
||||
// A sink to receive write events.
|
||||
// The requested metrics are the keys of the metrics that the caller is
|
||||
// interested in. The on_event callback will be called on each event
|
||||
// requested.
|
||||
class WriteEventSink final {
|
||||
public:
|
||||
WriteEventSink(absl::Span<const size_t> requested_metrics,
|
||||
std::initializer_list<WriteEvent> requested_events,
|
||||
WriteEventCallback on_event)
|
||||
: requested_metrics_(requested_metrics),
|
||||
on_event_(std::move(on_event)) {
|
||||
for (auto event : requested_events) {
|
||||
requested_events_mask_.set(static_cast<int>(event));
|
||||
}
|
||||
}
|
||||
|
||||
absl::Span<const size_t> requested_metrics() const {
|
||||
return requested_metrics_;
|
||||
}
|
||||
|
||||
bool requested_event(WriteEvent event) const {
|
||||
return requested_events_mask_.test(static_cast<int>(event));
|
||||
}
|
||||
|
||||
WriteEventSet requested_events_mask() const {
|
||||
return requested_events_mask_;
|
||||
}
|
||||
|
||||
WriteEventCallback TakeEventCallback() { return std::move(on_event_); }
|
||||
|
||||
private:
|
||||
absl::Span<const size_t> requested_metrics_;
|
||||
WriteEventSet requested_events_mask_;
|
||||
// The callback to be called on each event.
|
||||
WriteEventCallback on_event_;
|
||||
};
|
||||
/// A struct representing optional arguments that may be provided to an
|
||||
/// EventEngine Endpoint Write API call.
|
||||
///
|
||||
/// Passed as argument to an Endpoint \a Write
|
||||
struct WriteArgs {
|
||||
class WriteArgs final {
|
||||
public:
|
||||
WriteArgs() = default;
|
||||
WriteArgs(const WriteArgs&) = delete;
|
||||
WriteArgs& operator=(const WriteArgs&) = delete;
|
||||
WriteArgs(WriteArgs&&) = default;
|
||||
WriteArgs& operator=(WriteArgs&&) = default;
|
||||
|
||||
// A sink to receive write events.
|
||||
std::optional<WriteEventSink> TakeMetricsSink() {
|
||||
auto sink = std::move(metrics_sink_);
|
||||
metrics_sink_.reset();
|
||||
return sink;
|
||||
}
|
||||
|
||||
bool has_metrics_sink() const { return metrics_sink_.has_value(); }
|
||||
|
||||
void set_metrics_sink(WriteEventSink sink) {
|
||||
metrics_sink_ = std::move(sink);
|
||||
}
|
||||
|
||||
// Represents private information that may be passed by gRPC for
|
||||
// select endpoints expected to be used only within google.
|
||||
void* google_specific = nullptr;
|
||||
// TODO(ctiller): Remove this method once all callers are migrated to
|
||||
// metrics sink.
|
||||
void* GetDeprecatedAndDiscouragedGoogleSpecificPointer() {
|
||||
return google_specific_;
|
||||
}
|
||||
|
||||
void SetDeprecatedAndDiscouragedGoogleSpecificPointer(void* pointer) {
|
||||
google_specific_ = pointer;
|
||||
}
|
||||
|
||||
// A suggestion to the endpoint implementation to group data to be written
|
||||
// into frames of the specified max_frame_size. gRPC may use this
|
||||
// argument to dynamically control the max sizes of frames sent to a
|
||||
// receiver in response to high receiver memory pressure.
|
||||
int64_t max_frame_size;
|
||||
int64_t max_frame_size() const { return max_frame_size_; }
|
||||
|
||||
void set_max_frame_size(int64_t max_frame_size) {
|
||||
max_frame_size_ = max_frame_size;
|
||||
}
|
||||
|
||||
private:
|
||||
std::optional<WriteEventSink> metrics_sink_;
|
||||
void* google_specific_ = nullptr;
|
||||
int64_t max_frame_size_ = 1024 * 1024;
|
||||
};
|
||||
/// Writes data out on the connection.
|
||||
///
|
||||
|
@ -250,11 +354,22 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
/// statuses to \a on_writable. For example, callbacks might expect to
|
||||
/// receive CANCELLED on endpoint shutdown.
|
||||
virtual bool Write(absl::AnyInvocable<void(absl::Status)> on_writable,
|
||||
SliceBuffer* data, const WriteArgs* args) = 0;
|
||||
SliceBuffer* data, WriteArgs args) = 0;
|
||||
/// Returns an address in the format described in DNSResolver. The returned
|
||||
/// values are expected to remain valid for the life of the Endpoint.
|
||||
virtual const ResolvedAddress& GetPeerAddress() const = 0;
|
||||
virtual const ResolvedAddress& GetLocalAddress() const = 0;
|
||||
/// Returns the list of write metrics that the endpoint supports.
|
||||
/// The keys are used to identify the metrics in the GetMetricName and
|
||||
/// GetMetricKey APIs. The current value of the metric can be queried by
|
||||
/// adding a WriteEventSink to the WriteArgs of a Write call.
|
||||
virtual std::vector<size_t> AllWriteMetrics() = 0;
|
||||
/// Returns the name of the write metric with the given key.
|
||||
/// If the key is not found, returns std::nullopt.
|
||||
virtual std::optional<absl::string_view> GetMetricName(size_t key) = 0;
|
||||
/// Returns the key of the write metric with the given name.
|
||||
/// If the name is not found, returns std::nullopt.
|
||||
virtual std::optional<size_t> GetMetricKey(absl::string_view name) = 0;
|
||||
};
|
||||
|
||||
/// Called when a new connection is established.
|
||||
|
@ -336,7 +451,7 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
/// when the object is destroyed and all pending callbacks will be called
|
||||
/// shortly. If cancellation races with request completion, implementations
|
||||
/// may choose to either cancel or satisfy the request.
|
||||
class DNSResolver {
|
||||
class DNSResolver : public Extensible {
|
||||
public:
|
||||
/// Optional configuration for DNSResolvers.
|
||||
struct ResolverOptions {
|
||||
|
@ -474,7 +589,7 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
virtual bool Cancel(TaskHandle handle) = 0;
|
||||
};
|
||||
|
||||
/// Replace gRPC's default EventEngine factory.
|
||||
/// [DEPRECATED] Replace gRPC's default EventEngine factory.
|
||||
///
|
||||
/// Applications may call \a SetEventEngineFactory at any time to replace the
|
||||
/// default factory used within gRPC. EventEngines will be created when
|
||||
|
@ -483,18 +598,83 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
|
|||
/// To be certain that none of the gRPC-provided built-in EventEngines are
|
||||
/// created, applications must set a custom EventEngine factory method *before*
|
||||
/// grpc is initialized.
|
||||
// TODO(hork): delete once all known users have migrated away
|
||||
void SetEventEngineFactory(
|
||||
absl::AnyInvocable<std::unique_ptr<EventEngine>()> factory);
|
||||
absl::AnyInvocable<std::shared_ptr<EventEngine>()> factory);
|
||||
|
||||
/// Reset gRPC's EventEngine factory to the built-in default.
|
||||
/// [DEPRECATED] Reset gRPC's EventEngine factory to the built-in default.
|
||||
///
|
||||
/// Applications that have called \a SetEventEngineFactory can remove their
|
||||
/// custom factory using this method. The built-in EventEngine factories will be
|
||||
/// used going forward. This has no affect on any EventEngines that were created
|
||||
/// using the previous factories.
|
||||
//
|
||||
// TODO(hork): delete once all known users have migrated away
|
||||
void EventEngineFactoryReset();
|
||||
/// Create an EventEngine using the default factory.
|
||||
std::unique_ptr<EventEngine> CreateEventEngine();
|
||||
|
||||
/// Create a new EventEngine instance.
|
||||
std::shared_ptr<EventEngine> CreateEventEngine();
|
||||
|
||||
/// Set the default EventEngine instance, which will be used throughout gRPC
|
||||
///
|
||||
/// gRPC will hold a ref to this engine until either
|
||||
/// \a ShutdownDefaultEventEngine() is called or \a SetDefaultEventEngine() is
|
||||
/// called again with a different value. Passing a value of nullptr will cause
|
||||
/// gRPC to drop the ref it was holding without setting it to a new one.
|
||||
///
|
||||
/// Earlier calls to \a GetDefaultEventEngine will still hold a ref to the
|
||||
/// previous default engine instance, if any.
|
||||
void SetDefaultEventEngine(std::shared_ptr<EventEngine> engine);
|
||||
|
||||
/// Returns the default EventEngine instance.
|
||||
///
|
||||
/// Note that if SetDefaultEventEngine() has not been called, then the default
|
||||
/// EventEngine may be created and destroyed as needed, meaning that multiple
|
||||
/// calls to GetDefaultEventEngine() over a process's lifetime may return
|
||||
/// different instances. Callers are expected to call GetDefaultEventEngine()
|
||||
/// once and hold the returned reference for as long as they need the
|
||||
/// EventEngine instance.
|
||||
std::shared_ptr<EventEngine> GetDefaultEventEngine();
|
||||
|
||||
/// Resets gRPC to use one of the default internal EventEngines for all *new*
|
||||
/// \a GetDefaultEventEngine requests and blocks until all refs on the active
|
||||
/// default engine have been released (destroying that engine).
|
||||
///
|
||||
/// If you called \a SetDefaultEventEngine, you must call either
|
||||
/// \a ShutdownDefaultEventEngine or \a SetDefaultEventEngine(nullptr) at the
|
||||
/// end of your program. If you don't, the engine will never be destroyed.
|
||||
///
|
||||
/// If you want to reset the default engine to one of gRPC's internal versions
|
||||
/// without waiting for all references to be released on the current default
|
||||
/// engine, call \a SetDefaultEventEngine(nullptr) instead.
|
||||
void ShutdownDefaultEventEngine();
|
||||
|
||||
bool operator==(const EventEngine::TaskHandle& lhs,
|
||||
const EventEngine::TaskHandle& rhs);
|
||||
bool operator!=(const EventEngine::TaskHandle& lhs,
|
||||
const EventEngine::TaskHandle& rhs);
|
||||
std::ostream& operator<<(std::ostream& out,
|
||||
const EventEngine::TaskHandle& handle);
|
||||
bool operator==(const EventEngine::ConnectionHandle& lhs,
|
||||
const EventEngine::ConnectionHandle& rhs);
|
||||
bool operator!=(const EventEngine::ConnectionHandle& lhs,
|
||||
const EventEngine::ConnectionHandle& rhs);
|
||||
std::ostream& operator<<(std::ostream& out,
|
||||
const EventEngine::ConnectionHandle& handle);
|
||||
|
||||
namespace detail {
|
||||
std::string FormatHandleString(uint64_t key1, uint64_t key2);
|
||||
}
|
||||
|
||||
template <typename Sink>
|
||||
void AbslStringify(Sink& out, const EventEngine::ConnectionHandle& handle) {
|
||||
out.Append(detail::FormatHandleString(handle.keys[0], handle.keys[1]));
|
||||
}
|
||||
|
||||
template <typename Sink>
|
||||
void AbslStringify(Sink& out, const EventEngine::TaskHandle& handle) {
|
||||
out.Append(detail::FormatHandleString(handle.keys[0], handle.keys[1]));
|
||||
}
|
||||
|
||||
} // namespace experimental
|
||||
} // namespace grpc_event_engine
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_EXTENSIBLE_H
|
||||
#define GRPC_EVENT_ENGINE_EXTENSIBLE_H
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
namespace grpc_event_engine {
|
||||
namespace experimental {
|
||||
|
||||
|
@ -60,6 +60,9 @@ class Extensible {
|
|||
/// if (endpoint != nullptr) endpoint->Process();
|
||||
///
|
||||
virtual void* QueryExtension(absl::string_view /*id*/) { return nullptr; }
|
||||
|
||||
protected:
|
||||
~Extensible() = default;
|
||||
};
|
||||
|
||||
} // namespace experimental
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_INTERNAL_MEMORY_ALLOCATOR_IMPL_H
|
||||
#define GRPC_EVENT_ENGINE_INTERNAL_MEMORY_ALLOCATOR_IMPL_H
|
||||
|
||||
#include <grpc/event_engine/memory_request.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/event_engine/memory_request.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_event_engine {
|
||||
namespace experimental {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace internal {
|
|||
// with `SliceCast`. Both ways need to be declared (i.e. if
|
||||
// SliceCastable<A,B> exists, you should declare
|
||||
// SliceCastable<B,A> too).
|
||||
// The type has no members, it's just the existance of the specialization that
|
||||
// The type has no members, it's just the existence of the specialization that
|
||||
// unlocks SliceCast usage for a type pair.
|
||||
template <typename Result, typename T>
|
||||
struct SliceCastable;
|
||||
|
|
|
@ -12,13 +12,23 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP_TRACE_H
|
||||
#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP_TRACE_H
|
||||
#ifndef GRPC_EVENT_ENGINE_INTERNAL_WRITE_EVENT_H
|
||||
#define GRPC_EVENT_ENGINE_INTERNAL_WRITE_EVENT_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
namespace grpc_event_engine::experimental::internal {
|
||||
|
||||
#include "src/core/lib/debug/trace.h"
|
||||
// Use of this enum via this name is internal to gRPC.
|
||||
// API users should get this enumeration via the
|
||||
// EventEngine::Endpoint::WriteEvent.
|
||||
enum class WriteEvent {
|
||||
kSendMsg,
|
||||
kScheduled,
|
||||
kSent,
|
||||
kAcked,
|
||||
kClosed,
|
||||
kCount // Must be last.
|
||||
};
|
||||
|
||||
extern grpc_core::TraceFlag grpc_http_trace;
|
||||
} // namespace grpc_event_engine::experimental::internal
|
||||
|
||||
#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP_TRACE_H
|
||||
#endif // GRPC_EVENT_ENGINE_INTERNAL_WRITE_EVENT_H
|
|
@ -14,6 +14,9 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_MEMORY_ALLOCATOR_H
|
||||
#define GRPC_EVENT_ENGINE_MEMORY_ALLOCATOR_H
|
||||
|
||||
#include <grpc/event_engine/internal/memory_allocator_impl.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stdlib.h> // for abort()
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -21,10 +24,6 @@
|
|||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/event_engine/internal/memory_allocator_impl.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_event_engine {
|
||||
namespace experimental {
|
||||
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_MEMORY_REQUEST_H
|
||||
#define GRPC_EVENT_ENGINE_MEMORY_REQUEST_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_event_engine {
|
||||
namespace experimental {
|
||||
|
||||
|
@ -46,6 +45,24 @@ class MemoryRequest {
|
|||
size_t min() const { return min_; }
|
||||
size_t max() const { return max_; }
|
||||
|
||||
bool operator==(const MemoryRequest& other) const {
|
||||
return min_ == other.min_ && max_ == other.max_;
|
||||
}
|
||||
bool operator!=(const MemoryRequest& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
template <typename Sink>
|
||||
friend void AbslStringify(Sink& s, const MemoryRequest& r) {
|
||||
if (r.min_ == r.max_) {
|
||||
s.Append(std::to_string(r.min_));
|
||||
} else {
|
||||
s.Append(std::to_string(r.min_));
|
||||
s.Append("..");
|
||||
s.Append(std::to_string(r.max_));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
size_t min_;
|
||||
size_t max_;
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_SLICE_H
|
||||
#define GRPC_EVENT_ENGINE_SLICE_H
|
||||
|
||||
#include <grpc/event_engine/internal/slice_cast.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -23,11 +26,6 @@
|
|||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include <grpc/event_engine/internal/slice_cast.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
// This public slice definition largely based of the internal grpc_core::Slice
|
||||
// implementation. Changes to this implementation might warrant changes to the
|
||||
// internal grpc_core::Slice type as well.
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
#ifndef GRPC_EVENT_ENGINE_SLICE_BUFFER_H
|
||||
#define GRPC_EVENT_ENGINE_SLICE_BUFFER_H
|
||||
|
||||
#include <grpc/event_engine/internal/slice_cast.h>
|
||||
#include <grpc/event_engine/slice.h>
|
||||
#include <grpc/impl/codegen/slice.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/slice_buffer.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -23,14 +29,6 @@
|
|||
#include "absl/strings/string_view.h"
|
||||
#include "absl/utility/utility.h"
|
||||
|
||||
#include <grpc/event_engine/internal/slice_cast.h>
|
||||
#include <grpc/event_engine/slice.h>
|
||||
#include <grpc/impl/codegen/slice.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/slice_buffer.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_event_engine {
|
||||
namespace experimental {
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#ifndef GRPC_GRPC_H
|
||||
#define GRPC_GRPC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <grpc/byte_buffer.h>
|
||||
#include <grpc/impl/connectivity_state.h> // IWYU pragma: export
|
||||
#include <grpc/impl/grpc_types.h> // IWYU pragma: export
|
||||
|
@ -29,6 +27,7 @@
|
|||
#include <grpc/status.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpc/support/time.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -19,15 +19,15 @@
|
|||
#ifndef GRPC_GRPC_AUDIT_LOGGING_H
|
||||
#define GRPC_GRPC_AUDIT_LOGGING_H
|
||||
|
||||
#include <grpc/support/json.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include <grpc/support/json.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_core {
|
||||
namespace experimental {
|
||||
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
#ifndef GRPC_GRPC_CRL_PROVIDER_H
|
||||
#define GRPC_GRPC_CRL_PROVIDER_H
|
||||
|
||||
#include <grpc/credentials.h>
|
||||
#include <grpc/grpc_security.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include <grpc/credentials.h>
|
||||
#include <grpc/grpc_security.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_core {
|
||||
namespace experimental {
|
||||
|
||||
|
@ -82,7 +82,7 @@ absl::StatusOr<std::shared_ptr<CrlProvider>> CreateDirectoryReloaderCrlProvider(
|
|||
} // namespace experimental
|
||||
} // namespace grpc_core
|
||||
|
||||
// TODO(gtcooke94) - Mark with api macro when all wrapped langauges support C++
|
||||
// TODO(gtcooke94) - Mark with api macro when all wrapped languages support C++
|
||||
// in core APIs
|
||||
/**
|
||||
* EXPERIMENTAL API - Subject to change
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#ifndef GRPC_GRPC_POSIX_H
|
||||
#define GRPC_GRPC_POSIX_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
#ifndef GRPC_GRPC_SECURITY_H
|
||||
#define GRPC_GRPC_SECURITY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/grpc_security_constants.h>
|
||||
#include <grpc/status.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
#ifndef GRPC_IMPL_CALL_H
|
||||
#define GRPC_IMPL_CALL_H
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
|
||||
// Run a callback in the call's EventEngine.
|
||||
// Internal-only
|
||||
void grpc_call_run_in_event_engine(const grpc_call* call,
|
||||
|
|
|
@ -31,13 +31,15 @@
|
|||
#define GRPC_ARG_SERVER_CALL_METRIC_RECORDING \
|
||||
"grpc.server_call_metric_recording"
|
||||
/** Request that optional features default to off (regardless of what they
|
||||
usually default to) - to enable tight control over what gets enabled */
|
||||
usually default to) - to enable tight control over what gets enabled
|
||||
Boolean valued. Defaults to false. */
|
||||
#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack"
|
||||
/** Maximum number of concurrent incoming streams to allow on a http2
|
||||
connection. Int valued. */
|
||||
connection. Int valued. Deafult to -1(indicating no explicit limit).*/
|
||||
#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams"
|
||||
/** Maximum message length that the channel can receive. Int valued, bytes.
|
||||
-1 means unlimited. */
|
||||
-1 means unlimited. Defaults to 4MB(4*1024*1024 bytes). -1 means unlimited.
|
||||
*/
|
||||
#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH "grpc.max_receive_message_length"
|
||||
/** \deprecated For backward compatibility.
|
||||
* Use GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH instead. */
|
||||
|
@ -47,27 +49,31 @@
|
|||
#define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length"
|
||||
/** Maximum time that a channel may have no outstanding rpcs, after which the
|
||||
* server will close the connection. Int valued, milliseconds. INT_MAX means
|
||||
* unlimited. */
|
||||
* unlimited. Defaults to INT_MAX. */
|
||||
#define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms"
|
||||
/** Maximum time that a channel may exist. Int valued, milliseconds.
|
||||
* INT_MAX means unlimited. */
|
||||
/** Maximum amount of time in milliseconds that a connection may exist before it
|
||||
* will be gracefully shut down. Refer
|
||||
* https://github.com/grpc/proposal/blob/master/A9-server-side-conn-mgt.md for
|
||||
* more details. Int valued, defaults to INT_MAX (disabled). */
|
||||
#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms"
|
||||
/** Grace period after the channel reaches its max age. Int valued,
|
||||
milliseconds. INT_MAX means unlimited. */
|
||||
/** Grace period in milliseconds after connection reaches its max age for
|
||||
* outstanding RPCs to complete. Int valued, defaults to INT_MAX (disabled). */
|
||||
#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms"
|
||||
/** Timeout after the last RPC finishes on the client channel at which the
|
||||
* channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means
|
||||
* unlimited. The default value is 30 minutes and the min value is 1 second. */
|
||||
#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms"
|
||||
/** Enable/disable support for per-message compression. Defaults to 1, unless
|
||||
GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */
|
||||
/** Enable/disable support for per-message compression. Boolean valued. Defaults
|
||||
to true, unless GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults
|
||||
to false. */
|
||||
#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression"
|
||||
/** Experimental Arg. Enable/disable support for per-message decompression.
|
||||
Defaults to 1. If disabled, decompression will not be performed and the
|
||||
application will see the compressed message in the byte buffer. */
|
||||
#define GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION \
|
||||
"grpc.per_message_decompression"
|
||||
/** Initial stream ID for http2 transports. Int valued. */
|
||||
/** Initial stream ID for http2 transports. Int valued. Defaults to -1
|
||||
indicating use of default http2 setting initial stream ID (1). */
|
||||
#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \
|
||||
"grpc.http2.initial_sequence_number"
|
||||
/** Amount to read ahead on individual streams. Defaults to 64kb, larger
|
||||
|
@ -75,17 +81,22 @@
|
|||
NOTE: at some point we'd like to auto-tune this, and this parameter
|
||||
will become a no-op. Int valued, bytes. */
|
||||
#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes"
|
||||
/** How much memory to use for hpack decoding. Int valued, bytes. */
|
||||
/** How much memory to use for hpack decoding. Int valued, bytes. Defaults to -1
|
||||
indicating use of default http2 setting(4096 bytes). */
|
||||
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \
|
||||
"grpc.http2.hpack_table_size.decoder"
|
||||
/** How much memory to use for hpack encoding. Int valued, bytes. */
|
||||
/** How much memory to use for hpack encoding. Int valued, bytes. Defaults to -1
|
||||
indicating use of default http2 setting(4096 bytes). */
|
||||
#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \
|
||||
"grpc.http2.hpack_table_size.encoder"
|
||||
/** How big a frame are we willing to receive via HTTP2.
|
||||
Min 16384, max 16777215. Larger values give lower CPU usage for large
|
||||
messages, but more head of line blocking for small messages. */
|
||||
messages, but more head of line blocking for small messages. Defaults to
|
||||
-1(indicating no explicit max frame size), so it will take standard http/2
|
||||
specified max frame size to 16 KB. */
|
||||
#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size"
|
||||
/** Should BDP probing be performed? */
|
||||
/** Should BDP probing be performed?
|
||||
Boolean valued. Defaults to true(enabled). */
|
||||
#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe"
|
||||
/** (DEPRECATED) Does not have any effect.
|
||||
Earlier, this arg configured the minimum time between successive ping frames
|
||||
|
@ -109,19 +120,24 @@
|
|||
before the request is cancelled */
|
||||
#define GRPC_ARG_SERVER_MAX_UNREQUESTED_TIME_IN_SERVER_SECONDS \
|
||||
"grpc.server_max_unrequested_time_in_server"
|
||||
/** Channel arg to override the http2 :scheme header */
|
||||
/** Channel arg to override the http2 :scheme header. String valued. */
|
||||
#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme"
|
||||
/** How many pings can the client send before needing to send a
|
||||
data/header frame? (0 indicates that an infinite number of
|
||||
pings can be sent without sending a data frame or header frame) */
|
||||
/** How many pings can the client send before needing to send a data/header
|
||||
frame? (0 indicates that an infinite number of pings can be sent without
|
||||
sending a data frame or header frame).
|
||||
If experiment "max_pings_wo_data_throttle" is enabled, instead of pings being
|
||||
completely blocked, they are throttled.
|
||||
* Integer valued. Defaults to 2. */
|
||||
#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \
|
||||
"grpc.http2.max_pings_without_data"
|
||||
/** How many misbehaving pings the server can bear before sending goaway and
|
||||
closing the transport? (0 indicates that the server can bear an infinite
|
||||
number of misbehaving pings) */
|
||||
number of misbehaving pings)
|
||||
* Integer valued. Defaults to 2. */
|
||||
#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes"
|
||||
/** How much data are we willing to queue up per stream if
|
||||
GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */
|
||||
GRPC_WRITE_BUFFER_HINT is set? This is an upper bound
|
||||
* Integer valued, bytes. Defaults to 65535 bytes. */
|
||||
#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size"
|
||||
/** Should we allow receipt of true-binary data on http2 connections?
|
||||
Defaults to on (1) */
|
||||
|
@ -134,33 +150,44 @@
|
|||
#define GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE \
|
||||
"grpc.experimental.http2.enable_preferred_frame_size"
|
||||
/** After a duration of this time the client/server pings its peer to see if the
|
||||
transport is still alive. Int valued, milliseconds. */
|
||||
transport is still alive. Int valued, milliseconds. Defaults to 7200000 (2
|
||||
hours). */
|
||||
#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms"
|
||||
/** After waiting for a duration of this time, if the keepalive ping sender does
|
||||
not receive the ping ack, it will close the transport. Int valued,
|
||||
milliseconds. */
|
||||
milliseconds. Defaults to 20000 (20 seonds). */
|
||||
#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms"
|
||||
/** Is it permissible to send keepalive pings from the client without any
|
||||
outstanding streams. Int valued, 0(false)/1(true). */
|
||||
outstanding streams. Int valued, 0(false)/1(true). Defaults to 0. */
|
||||
#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \
|
||||
"grpc.keepalive_permit_without_calls"
|
||||
/** Default authority to pass if none specified on call construction. A string.
|
||||
* */
|
||||
#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority"
|
||||
/** Primary user agent: goes at the start of the user-agent metadata
|
||||
sent on each request. A string. */
|
||||
sent on each request. A string. Defaults to empty string(""). */
|
||||
#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent"
|
||||
/** Secondary user agent: goes at the end of the user-agent metadata
|
||||
sent on each request. A string. */
|
||||
#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent"
|
||||
/** The minimum time between subsequent connection attempts, in ms */
|
||||
/** The minimum time between subsequent connection attempts, in ms. Refer to
|
||||
* MIN_CONNECT_TIMEOUT from
|
||||
* https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. Defaults
|
||||
* to 20 seconds. */
|
||||
#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms"
|
||||
/** The maximum time between subsequent connection attempts, in ms */
|
||||
/** The maximum time between subsequent connection attempts, in ms. Refer to
|
||||
* MAX_BACKOFF from
|
||||
* https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. Defaults
|
||||
* to 120 seconds. */
|
||||
#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms"
|
||||
/** The time between the first and second connection attempts, in ms */
|
||||
/** The time between the first and second connection attempts, in ms. Refer to
|
||||
* INITIAL_BACKOFF from
|
||||
* https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md. Defaults
|
||||
* to 1 second. */
|
||||
#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \
|
||||
"grpc.initial_reconnect_backoff_ms"
|
||||
/** Minimum amount of time between DNS resolutions, in ms */
|
||||
/** Minimum amount of time between DNS resolutions, in ms. Defaults to 30
|
||||
* seconds. */
|
||||
#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \
|
||||
"grpc.dns_min_time_between_resolutions_ms"
|
||||
/** The timeout used on servers for finishing handshaking on an incoming
|
||||
|
@ -176,10 +203,10 @@
|
|||
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override"
|
||||
/** If non-zero, a pointer to a session cache (a pointer of type
|
||||
grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch
|
||||
an appropriate pointer arg vtable) */
|
||||
an appropriate pointer arg vtable). */
|
||||
#define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache"
|
||||
/** If non-zero, it will determine the maximum frame size used by TSI's frame
|
||||
* protector.
|
||||
* protector. Defaults to zero.
|
||||
*/
|
||||
#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size"
|
||||
/** Maximum metadata size (soft limit), in bytes. Note this limit applies to the
|
||||
|
@ -198,17 +225,20 @@
|
|||
#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport"
|
||||
/** If non-zero, a pointer to a buffer pool (a pointer of type
|
||||
* grpc_resource_quota*). (use grpc_resource_quota_arg_vtable() to fetch an
|
||||
* appropriate pointer arg vtable) */
|
||||
* appropriate pointer arg vtable). */
|
||||
#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota"
|
||||
/** If non-zero, expand wildcard addresses to a list of local addresses. */
|
||||
/** If non-zero, expand wildcard addresses to a list of local addresses. Boolean
|
||||
* valued. */
|
||||
#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs"
|
||||
/** Service config data in JSON form.
|
||||
This value will be ignored if the name resolver returns a service config. */
|
||||
This value will be ignored if the name resolver returns a service config. A
|
||||
string value. */
|
||||
#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config"
|
||||
/** Disable looking up the service config via the name resolver. */
|
||||
/** Disable looking up the service config via the name resolver. Boolean valued.
|
||||
* Defaults to true. */
|
||||
#define GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION \
|
||||
"grpc.service_config_disable_resolution"
|
||||
/** LB policy name. */
|
||||
/** LB policy name. A string value.*/
|
||||
#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name"
|
||||
/** Cap for ring size in the ring_hash LB policy. The min and max ring size
|
||||
values set in the LB policy config will be capped to this value.
|
||||
|
@ -221,24 +251,23 @@
|
|||
/** The maximum amount of memory used by trace events per channel trace node.
|
||||
* Once the maximum is reached, subsequent events will evict the oldest events
|
||||
* from the buffer. The unit for this knob is bytes. Setting it to zero causes
|
||||
* channel tracing to be disabled. */
|
||||
* channel tracing to be disabled. Defaults to (1024 * 4) bytes. */
|
||||
#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \
|
||||
"grpc.max_channel_trace_event_memory_per_node"
|
||||
/** If non-zero, gRPC library will track stats and information at at per channel
|
||||
* level. Disabling channelz naturally disables channel tracing. The default
|
||||
* is for channelz to be enabled. */
|
||||
#define GRPC_ARG_ENABLE_CHANNELZ "grpc.enable_channelz"
|
||||
/** If non-zero, Cronet transport will coalesce packets to fewer frames
|
||||
* when possible. */
|
||||
#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \
|
||||
"grpc.use_cronet_packet_coalescing"
|
||||
/** Channel arg (integer) setting how large a slice to try and read from the
|
||||
wire each time recvmsg (or equivalent) is called **/
|
||||
wire each time recvmsg (or equivalent). Range varied from 1
|
||||
to (32 * 1024 * 1024) bytes. Defaults to 8192 bytes. **/
|
||||
#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size"
|
||||
/** Note this is not a "channel arg" key. This is the default slice size to use
|
||||
* when trying to read from the wire if the GRPC_ARG_TCP_READ_CHUNK_SIZE
|
||||
* channel arg is unspecified. */
|
||||
#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192
|
||||
/** Minimum read chunk size defaults to 256 bytes. Range varies from 1 to (32 *
|
||||
* 1024 * 1024) bytes. */
|
||||
#define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \
|
||||
"grpc.experimental.tcp_min_read_chunk_size"
|
||||
#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \
|
||||
|
@ -257,10 +286,12 @@
|
|||
issued by the tcp_write(). By default, this is set to 4. */
|
||||
#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \
|
||||
"grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends"
|
||||
/* Overrides the TCP socket recieve buffer size, SO_RCVBUF. */
|
||||
/* Overrides the TCP socket receive buffer size, SO_RCVBUF.
|
||||
Default value is -1(kReadBufferSizeUnset) indicating that the system will
|
||||
decide the buffer size. Range varies from 0 to INT_MAX. */
|
||||
#define GRPC_ARG_TCP_RECEIVE_BUFFER_SIZE "grpc.tcp_receive_buffer_size"
|
||||
/* Timeout in milliseconds to use for calls to the grpclb load balancer.
|
||||
If 0 or unset, the balancer calls will have no deadline. */
|
||||
If 0 or unset, the balancer calls will have no deadline. Defaults to 0 ms. */
|
||||
#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms"
|
||||
/* Specifies the xDS bootstrap config as a JSON string.
|
||||
FOR TESTING PURPOSES ONLY -- DO NOT USE IN PRODUCTION.
|
||||
|
@ -275,7 +306,7 @@
|
|||
"grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_config"
|
||||
/* Timeout in milliseconds to wait for the serverlist from the grpclb load
|
||||
balancer before using fallback backend addresses from the resolver.
|
||||
If 0, enter fallback mode immediately. Default value is 10000. */
|
||||
If 0, enter fallback mode immediately. Default value is 10000ms. */
|
||||
#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms"
|
||||
/* Experimental Arg. Channel args to be used for the control-plane channel
|
||||
* created to the grpclb load balancers. This is a pointer arg whose value is a
|
||||
|
@ -288,9 +319,6 @@
|
|||
over to the next priority. Default value is 10 seconds. */
|
||||
#define GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS \
|
||||
"grpc.priority_failover_timeout_ms"
|
||||
/** If non-zero, grpc server's cronet compression workaround will be enabled */
|
||||
#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \
|
||||
"grpc.workaround.cronet_compression"
|
||||
/** String defining the optimization target for a channel.
|
||||
Can be: "latency" - attempt to minimize latency at the cost of throughput
|
||||
"blend" - try to balance latency and throughput
|
||||
|
@ -323,13 +351,15 @@
|
|||
/** Channel arg that carries the bridged objective c object for custom metrics
|
||||
* logging filter. */
|
||||
#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context"
|
||||
/** If non-zero, client authority filter is disabled for the channel */
|
||||
/** If non-zero, client authority filter is disabled for the channel.
|
||||
* Boolean valued. Defaults to false. */
|
||||
#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \
|
||||
"grpc.disable_client_authority_filter"
|
||||
/** If set to zero, disables use of http proxies. Enabled by default. */
|
||||
#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy"
|
||||
/** Channel arg to set http proxy per channel. If set, the channel arg
|
||||
* value will be preferred over the environment variable settings. */
|
||||
* value will be preferred over the environment variable settings. String
|
||||
* value. */
|
||||
#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy"
|
||||
/** Specifies an HTTP proxy to use for individual addresses.
|
||||
* The proxy must be specified as an IP address, not a DNS name.
|
||||
|
@ -345,7 +375,7 @@
|
|||
agent is surfaced by default. */
|
||||
#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent"
|
||||
/** If set, inhibits health checking (which may be enabled via the
|
||||
* service config.) */
|
||||
* service config.). Boolean valued. Defaults to false. */
|
||||
#define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking"
|
||||
/** If enabled, the channel's DNS resolver queries for SRV records.
|
||||
* This is useful only when using the "grpclb" load balancing policy,
|
||||
|
@ -354,17 +384,17 @@
|
|||
* https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md
|
||||
* https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md
|
||||
* Note that this works only with the "ares" DNS resolver; it isn't supported
|
||||
* by the "native" DNS resolver. */
|
||||
* by the "native" DNS resolver. Boolean valued. Defaults to false. */
|
||||
#define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries"
|
||||
/** If set, determines an upper bound on the number of milliseconds that the
|
||||
* c-ares based DNS resolver will wait on queries before cancelling them.
|
||||
* The default value is 120,000. Setting this to "0" will disable the
|
||||
* The default value is 120,000ms. Setting this to "0" will disable the
|
||||
* overall timeout entirely. Note that this doesn't include internal c-ares
|
||||
* timeouts/backoff/retry logic, and so the actual DNS resolution may time out
|
||||
* sooner than the value specified here. */
|
||||
#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout"
|
||||
/** If set, uses a local subchannel pool within the channel. Otherwise, uses the
|
||||
* global subchannel pool. */
|
||||
* global subchannel pool. Boolean valued. Defaults to false. */
|
||||
#define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool"
|
||||
/** gRPC Objective-C channel pooling domain string. */
|
||||
#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain"
|
||||
|
@ -396,6 +426,10 @@
|
|||
* If unspecified, it is unlimited */
|
||||
#define GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS \
|
||||
"grpc.max_allowed_incoming_connections"
|
||||
/** Configure per-channel or per-server stats plugins. */
|
||||
#define GRPC_ARG_EXPERIMENTAL_STATS_PLUGINS "grpc.experimental.stats_plugins"
|
||||
/** If non-zero, allow security frames to be sent and received. */
|
||||
#define GRPC_ARG_SECURITY_FRAME_ALLOWED "grpc.security_frame_allowed"
|
||||
/** \} */
|
||||
|
||||
#endif /* GRPC_IMPL_CHANNEL_ARG_NAMES_H */
|
||||
|
|
|
@ -41,8 +41,9 @@ extern "C" {
|
|||
* Its value is an int from the \a grpc_compression_algorithm enum. */
|
||||
#define GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM \
|
||||
"grpc.default_compression_algorithm"
|
||||
/** Default compression level for the channel.
|
||||
* Its value is an int from the \a grpc_compression_level enum. */
|
||||
/** Set the default compression level for the channel.
|
||||
* Valid values are defined by the enum type grpc_compression_level, defaults to
|
||||
* GRPC_COMPRESS_LEVEL_NONE. */
|
||||
#define GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL "grpc.default_compression_level"
|
||||
/** Compression algorithms supported by the channel.
|
||||
* Its value is a bitset (an int). Bits correspond to algorithms in \a
|
||||
|
|
|
@ -21,14 +21,13 @@
|
|||
|
||||
// IWYU pragma: private, include <grpc/grpc.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <grpc/impl/channel_arg_names.h>
|
||||
#include <grpc/impl/compression_types.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/status.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpc/support/time.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
|
||||
// IWYU pragma: private, include <grpc/slice.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct grpc_slice grpc_slice;
|
||||
|
||||
|
@ -74,7 +73,7 @@ struct grpc_slice {
|
|||
} data;
|
||||
};
|
||||
|
||||
#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 6
|
||||
#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 3
|
||||
|
||||
/** Represents an expandable array of slices, to be interpreted as a
|
||||
single item. */
|
||||
|
|
|
@ -38,6 +38,7 @@ header "byte_buffer.h"
|
|||
header "impl/propagation_bits.h"
|
||||
header "impl/slice_type.h"
|
||||
header "load_reporting.h"
|
||||
header "passive_listener.h"
|
||||
header "slice.h"
|
||||
header "slice_buffer.h"
|
||||
header "status.h"
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright 2024 The gRPC Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef GRPC_PASSIVE_LISTENER_H
|
||||
#define GRPC_PASSIVE_LISTENER_H
|
||||
|
||||
#include <grpc/event_engine/event_engine.h>
|
||||
#include <grpc/grpc.h>
|
||||
|
||||
#include <memory>
|
||||
// #include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_core {
|
||||
class Server;
|
||||
|
||||
namespace experimental {
|
||||
class PassiveListenerImpl;
|
||||
|
||||
/// -- EXPERIMENTAL API --
|
||||
/// Interface for used for Server Endpoint injection.
|
||||
class PassiveListener {
|
||||
public:
|
||||
virtual ~PassiveListener() = default;
|
||||
/// -- EXPERIMENTAL API --
|
||||
///
|
||||
/// Takes an Endpoint for an established connection, and treats it as if the
|
||||
/// connection had been accepted by the server.
|
||||
///
|
||||
/// The server must be started before endpoints can be accepted.
|
||||
virtual absl::Status AcceptConnectedEndpoint(
|
||||
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
|
||||
endpoint) = 0;
|
||||
|
||||
/// -- EXPERIMENTAL API --
|
||||
///
|
||||
/// Takes a connected file descriptor, and treats it as if the server had
|
||||
/// accepted the connection itself.
|
||||
///
|
||||
/// Returns a failure status if the server's active EventEngine does not
|
||||
/// support Endpoint creation from fds.
|
||||
virtual absl::Status AcceptConnectedFd(int fd) = 0;
|
||||
};
|
||||
|
||||
} // namespace experimental
|
||||
} // namespace grpc_core
|
||||
|
||||
absl::Status grpc_server_add_passive_listener(
|
||||
grpc_core::Server* server, grpc_server_credentials* credentials,
|
||||
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
|
||||
passive_listener);
|
||||
|
||||
#endif /* GRPC_PASSIVE_LISTENER_H */
|
|
@ -146,7 +146,7 @@ typedef enum {
|
|||
GRPC_STATUS_DATA_LOSS = 15,
|
||||
|
||||
/** Force users to include a default branch: */
|
||||
GRPC_STATUS__DO_NOT_USE = -1
|
||||
GRPC_STATUS__DO_NOT_USE = 0x7fffffffu,
|
||||
} grpc_status_code;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
#ifndef GRPC_SUPPORT_ALLOC_H
|
||||
#define GRPC_SUPPORT_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -79,17 +79,4 @@
|
|||
#error could not determine platform for atm
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Adds \a delta to \a *value, clamping the result to the range specified
|
||||
by \a min and \a max. Returns the new value. */
|
||||
gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm* value, gpr_atm delta,
|
||||
gpr_atm min, gpr_atm max);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GRPC_SUPPORT_ATM_H */
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
#ifndef GRPC_SUPPORT_JSON_H
|
||||
#define GRPC_SUPPORT_JSON_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/types/variant.h"
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
namespace grpc_core {
|
||||
namespace experimental {
|
||||
|
@ -73,27 +73,8 @@ class Json {
|
|||
json.value_ = NumberValue{std::move(str)};
|
||||
return json;
|
||||
}
|
||||
static Json FromNumber(int32_t value) {
|
||||
Json json;
|
||||
json.value_ = NumberValue{absl::StrCat(value)};
|
||||
return json;
|
||||
}
|
||||
static Json FromNumber(uint32_t value) {
|
||||
Json json;
|
||||
json.value_ = NumberValue{absl::StrCat(value)};
|
||||
return json;
|
||||
}
|
||||
static Json FromNumber(int64_t value) {
|
||||
Json json;
|
||||
json.value_ = NumberValue{absl::StrCat(value)};
|
||||
return json;
|
||||
}
|
||||
static Json FromNumber(uint64_t value) {
|
||||
Json json;
|
||||
json.value_ = NumberValue{absl::StrCat(value)};
|
||||
return json;
|
||||
}
|
||||
static Json FromNumber(double value) {
|
||||
template <typename T>
|
||||
static std::enable_if_t<std::is_arithmetic_v<T>, Json> FromNumber(T value) {
|
||||
Json json;
|
||||
json.value_ = NumberValue{absl::StrCat(value)};
|
||||
return json;
|
||||
|
@ -148,46 +129,46 @@ class Json {
|
|||
|
||||
// Moveable.
|
||||
Json(Json&& other) noexcept : value_(std::move(other.value_)) {
|
||||
other.value_ = absl::monostate();
|
||||
other.value_ = std::monostate();
|
||||
}
|
||||
Json& operator=(Json&& other) noexcept {
|
||||
value_ = std::move(other.value_);
|
||||
other.value_ = absl::monostate();
|
||||
other.value_ = std::monostate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Returns the JSON type.
|
||||
Type type() const {
|
||||
struct ValueFunctor {
|
||||
Json::Type operator()(const absl::monostate&) { return Type::kNull; }
|
||||
Json::Type operator()(const std::monostate&) { return Type::kNull; }
|
||||
Json::Type operator()(bool) { return Type::kBoolean; }
|
||||
Json::Type operator()(const NumberValue&) { return Type::kNumber; }
|
||||
Json::Type operator()(const std::string&) { return Type::kString; }
|
||||
Json::Type operator()(const Object&) { return Type::kObject; }
|
||||
Json::Type operator()(const Array&) { return Type::kArray; }
|
||||
};
|
||||
return absl::visit(ValueFunctor(), value_);
|
||||
return std::visit(ValueFunctor(), value_);
|
||||
}
|
||||
|
||||
// Payload accessor for kBoolean.
|
||||
// Must not be called for other types.
|
||||
bool boolean() const { return absl::get<bool>(value_); }
|
||||
bool boolean() const { return std::get<bool>(value_); }
|
||||
|
||||
// Payload accessor for kNumber or kString.
|
||||
// Must not be called for other types.
|
||||
const std::string& string() const {
|
||||
const NumberValue* num = absl::get_if<NumberValue>(&value_);
|
||||
const NumberValue* num = std::get_if<NumberValue>(&value_);
|
||||
if (num != nullptr) return num->value;
|
||||
return absl::get<std::string>(value_);
|
||||
return std::get<std::string>(value_);
|
||||
}
|
||||
|
||||
// Payload accessor for kObject.
|
||||
// Must not be called for other types.
|
||||
const Object& object() const { return absl::get<Object>(value_); }
|
||||
const Object& object() const { return std::get<Object>(value_); }
|
||||
|
||||
// Payload accessor for kArray.
|
||||
// Must not be called for other types.
|
||||
const Array& array() const { return absl::get<Array>(value_); }
|
||||
const Array& array() const { return std::get<Array>(value_); }
|
||||
|
||||
bool operator==(const Json& other) const { return value_ == other.value_; }
|
||||
bool operator!=(const Json& other) const { return !(*this == other); }
|
||||
|
@ -200,12 +181,12 @@ class Json {
|
|||
return value == other.value;
|
||||
}
|
||||
};
|
||||
using Value = absl::variant<absl::monostate, // kNull
|
||||
bool, // kBoolean
|
||||
NumberValue, // kNumber
|
||||
std::string, // kString
|
||||
Object, // kObject
|
||||
Array>; // kArray
|
||||
using Value = std::variant<std::monostate, // kNull
|
||||
bool, // kBoolean
|
||||
NumberValue, // kNumber
|
||||
std::string, // kString
|
||||
Object, // kObject
|
||||
Array>; // kArray
|
||||
|
||||
explicit Json(Value value) : value_(std::move(value)) {}
|
||||
|
||||
|
|
|
@ -19,92 +19,65 @@
|
|||
#ifndef GRPC_SUPPORT_LOG_H
|
||||
#define GRPC_SUPPORT_LOG_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h> /* for abort() */
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** GPR log API.
|
||||
|
||||
Usage (within grpc):
|
||||
|
||||
int argument1 = 3;
|
||||
char* argument2 = "hello";
|
||||
gpr_log(GPR_DEBUG, "format string %d", argument1);
|
||||
gpr_log(GPR_INFO, "hello world");
|
||||
gpr_log(GPR_ERROR, "%d %s!!", argument1, argument2); */
|
||||
|
||||
/** The severity of a log message - use the #defines below when calling into
|
||||
gpr_log to additionally supply file and line data */
|
||||
grpc_absl_log to additionally supply file and line data */
|
||||
typedef enum gpr_log_severity {
|
||||
GPR_LOG_SEVERITY_DEBUG,
|
||||
GPR_LOG_SEVERITY_INFO,
|
||||
GPR_LOG_SEVERITY_ERROR
|
||||
} gpr_log_severity;
|
||||
|
||||
/** Returns a string representation of the log severity */
|
||||
GPRAPI const char* gpr_log_severity_string(gpr_log_severity severity);
|
||||
|
||||
/** Macros to build log contexts at various severity levels */
|
||||
#define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
|
||||
#define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO
|
||||
#define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR
|
||||
|
||||
/** Log a message. It's advised to use GPR_xxx above to generate the context
|
||||
* for each message */
|
||||
GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity,
|
||||
const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
|
||||
/**
|
||||
* EXPERIMENTAL. API stability not guaranteed.
|
||||
* Should only be used from gRPC PHP and RUBY.
|
||||
* This will be removed once Ruby and PHP can start using C++ APIs.
|
||||
* We would replace this with calls to absl LOG functions.
|
||||
* grpc_absl_log is equivalent to
|
||||
* ABSL_LOG(severity) << message_str;
|
||||
* **/
|
||||
GPRAPI void grpc_absl_log(const char* file, int line, gpr_log_severity severity,
|
||||
const char* message_str);
|
||||
|
||||
GPRAPI int gpr_should_log(gpr_log_severity severity);
|
||||
/**
|
||||
* EXPERIMENTAL. API stability not guaranteed.
|
||||
* Should only be used from gRPC PHP and RUBY.
|
||||
* This will be removed once Ruby and PHP can start using C++ APIs.
|
||||
* We would replace this with calls to absl LOG functions.
|
||||
* grpc_absl_log_int is equivalent to
|
||||
* ABSL_LOG(severity) << message_str << num;
|
||||
* **/
|
||||
GPRAPI void grpc_absl_log_int(const char* file, int line,
|
||||
gpr_log_severity severity,
|
||||
const char* message_str, intptr_t num);
|
||||
|
||||
GPRAPI void gpr_log_message(const char* file, int line,
|
||||
gpr_log_severity severity, const char* message);
|
||||
|
||||
/** Set global log verbosity */
|
||||
GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
|
||||
/**
|
||||
* EXPERIMENTAL. API stability not guaranteed.
|
||||
* Should only be used from gRPC PHP and RUBY.
|
||||
* This will be removed once Ruby and PHP can start using C++ APIs.
|
||||
* We would replace this with calls to absl LOG functions.
|
||||
* grpc_absl_log_str is equivalent to
|
||||
* ABSL_LOG(severity) << message_str1 << message_str2;
|
||||
* **/
|
||||
GPRAPI void grpc_absl_log_str(const char* file, int line,
|
||||
gpr_log_severity severity,
|
||||
const char* message_str1,
|
||||
const char* message_str2);
|
||||
|
||||
GPRAPI void gpr_log_verbosity_init(void);
|
||||
|
||||
/** Log overrides: applications can use this API to intercept logging calls
|
||||
and use their own implementations */
|
||||
|
||||
struct gpr_log_func_args {
|
||||
const char* file;
|
||||
int line;
|
||||
gpr_log_severity severity;
|
||||
const char* message;
|
||||
};
|
||||
|
||||
typedef struct gpr_log_func_args gpr_log_func_args;
|
||||
|
||||
typedef void (*gpr_log_func)(gpr_log_func_args* args);
|
||||
GPRAPI void gpr_set_log_function(gpr_log_func func);
|
||||
|
||||
GPRAPI void gpr_assertion_failed(const char* filename, int line,
|
||||
const char* message) GPR_ATTRIBUTE_NORETURN;
|
||||
|
||||
/** abort() the process if x is zero, having written a line to the log.
|
||||
|
||||
Intended for internal invariants. If the error can be recovered from,
|
||||
without the possibility of corruption, or might best be reflected via
|
||||
an exception in a higher-level language, consider returning error code. */
|
||||
#define GPR_ASSERT(x) \
|
||||
do { \
|
||||
if (GPR_UNLIKELY(!(x))) { \
|
||||
gpr_assertion_failed(__FILE__, __LINE__, #x); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(x)
|
||||
#else
|
||||
#define GPR_DEBUG_ASSERT(x) GPR_ASSERT(true || (x))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -15,20 +15,26 @@
|
|||
#ifndef GRPC_SUPPORT_METRICS_H
|
||||
#define GRPC_SUPPORT_METRICS_H
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include <grpc/event_engine/endpoint_config.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
namespace grpc_core {
|
||||
namespace experimental {
|
||||
|
||||
// Configuration (scope) for a specific client channel to be used for stats
|
||||
// plugins.
|
||||
// plugins. For some components like XdsClient where the same XdsClient instance
|
||||
// can be shared across multiple channels that share the same target name but
|
||||
// have different default authority and channel arguments, the component uses
|
||||
// the configuration from the first channel that uses this XdsClient instance to
|
||||
// determine StatsPluginChannelScope.
|
||||
class StatsPluginChannelScope {
|
||||
public:
|
||||
StatsPluginChannelScope(absl::string_view target,
|
||||
absl::string_view default_authority)
|
||||
: target_(target), default_authority_(default_authority) {}
|
||||
StatsPluginChannelScope(
|
||||
absl::string_view target, absl::string_view default_authority,
|
||||
const grpc_event_engine::experimental::EndpointConfig& args)
|
||||
: target_(target), default_authority_(default_authority), args_(args) {}
|
||||
|
||||
/// Returns the target used for creating the channel in the canonical form.
|
||||
/// (Canonicalized target definition -
|
||||
|
@ -36,13 +42,22 @@ class StatsPluginChannelScope {
|
|||
absl::string_view target() const { return target_; }
|
||||
/// Returns the default authority for the channel.
|
||||
absl::string_view default_authority() const { return default_authority_; }
|
||||
/// Returns channel arguments. THIS METHOD IS EXPERIMENTAL.
|
||||
// TODO(roth, ctiller, yashkt): Find a better representation for
|
||||
// channel args before de-experimentalizing this API.
|
||||
const grpc_event_engine::experimental::EndpointConfig& experimental_args()
|
||||
const {
|
||||
return args_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Disable copy constructor and copy-assignment operator.
|
||||
StatsPluginChannelScope(const StatsPluginChannelScope&) = delete;
|
||||
StatsPluginChannelScope& operator=(const StatsPluginChannelScope&) = delete;
|
||||
|
||||
absl::string_view target_;
|
||||
absl::string_view default_authority_;
|
||||
const grpc_event_engine::experimental::EndpointConfig& args_;
|
||||
};
|
||||
|
||||
} // namespace experimental
|
||||
|
|
|
@ -26,17 +26,20 @@
|
|||
#define GRPC_DEPRECATED(reason)
|
||||
#endif // __cplusplus >= 201402L
|
||||
|
||||
#ifndef GPR_DISABLE_ABSEIL_SYNC
|
||||
/*
|
||||
* Defines GPR_ABSEIL_SYNC to use synchronization features from Abseil
|
||||
*
|
||||
* You can opt for gRPC's native synchronization by enabling
|
||||
* GPR_DISABLE_ABSEIL_SYNC. However, this flag is temporary and will be
|
||||
* removed once the Abseil synchronization is stabilized.
|
||||
* If you encounter any issues with this feature, please report them
|
||||
* by filing a bug at https://github.com/grpc/grpc.
|
||||
*/
|
||||
#ifndef GPR_ABSEIL_SYNC
|
||||
#if defined(__APPLE__)
|
||||
// This is disabled on Apple platforms because macos/grpc_basictests_c_cpp
|
||||
// fails with this. https://github.com/grpc/grpc/issues/23661
|
||||
#else
|
||||
#define GPR_ABSEIL_SYNC 1
|
||||
#endif
|
||||
#endif // GPR_ABSEIL_SYNC
|
||||
#endif // GPR_DISABLE_ABSEIL_SYNC
|
||||
|
||||
/* Get windows.h included everywhere (we need it) */
|
||||
#if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
|
||||
|
@ -172,7 +175,6 @@
|
|||
#if __ANDROID_API__ < 21
|
||||
#error "Requires Android API v21 and above"
|
||||
#endif
|
||||
#define GPR_SUPPORT_BINDER_TRANSPORT 1
|
||||
// TODO(apolcyn): re-evaluate support for c-ares
|
||||
// on android after upgrading our c-ares dependency.
|
||||
// See https://github.com/grpc/grpc/issues/18038.
|
||||
|
@ -195,6 +197,12 @@
|
|||
#define GPR_HAS_PTHREAD_H 1
|
||||
#define GPR_GETPID_IN_UNISTD_H 1
|
||||
#define GPR_SUPPORT_CHANNELS_FROM_FD 1
|
||||
#if defined(__has_include)
|
||||
#if __has_include(<android/ndk-version.h>)
|
||||
#include <android/ndk-version.h>
|
||||
#endif /* __has_include(<android/ndk-version.h>) */
|
||||
#endif /* defined(__has_include) */
|
||||
#include <linux/version.h>
|
||||
#elif defined(__linux__)
|
||||
#define GPR_PLATFORM_STRING "linux"
|
||||
#ifndef _BSD_SOURCE
|
||||
|
@ -272,6 +280,9 @@
|
|||
#define GPR_PLATFORM_STRING "ios"
|
||||
#define GPR_CPU_IPHONE 1
|
||||
#define GRPC_CFSTREAM 1
|
||||
#ifndef GRPC_IOS_EVENT_ENGINE_CLIENT
|
||||
#define GRPC_IOS_EVENT_ENGINE_CLIENT 1
|
||||
#endif /* GRPC_IOS_EVENT_ENGINE_CLIENT */
|
||||
/* the c-ares resolver isn't safe to enable on iOS */
|
||||
#define GRPC_ARES 0
|
||||
#else /* TARGET_OS_IPHONE */
|
||||
|
@ -743,6 +754,22 @@ extern void gpr_unreachable_code(const char* reason, const char* file,
|
|||
#endif
|
||||
#endif /* GPR_ATTRIBUTE_NOINLINE */
|
||||
|
||||
#ifndef GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION
|
||||
#ifdef __cplusplus
|
||||
#if GPR_HAS_CPP_ATTRIBUTE(clang::always_inline)
|
||||
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION [[clang::always_inline]]
|
||||
#elif GPR_HAS_ATTRIBUTE(always_inline)
|
||||
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION __attribute__((always_inline))
|
||||
#else
|
||||
// TODO(ctiller): add __forceinline for MSVC
|
||||
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION
|
||||
#endif
|
||||
#else
|
||||
// Disable for C code
|
||||
#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION
|
||||
#endif
|
||||
#endif /* GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION */
|
||||
|
||||
#ifndef GPR_NO_UNIQUE_ADDRESS
|
||||
#if GPR_HAS_CPP_ATTRIBUTE(no_unique_address)
|
||||
#define GPR_NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||
|
@ -817,6 +844,12 @@ extern void gpr_unreachable_code(const char* reason, const char* file,
|
|||
#endif /* __GPR_WINDOWS */
|
||||
#endif /* GRPC_ALLOW_EXCEPTIONS */
|
||||
|
||||
#ifdef __has_builtin
|
||||
#define GRPC_HAS_BUILTIN(a) __has_builtin(a)
|
||||
#else
|
||||
#define GRPC_HAS_BUILTIN(a) 0
|
||||
#endif
|
||||
|
||||
/* Use GPR_LIKELY only in cases where you are sure that a certain outcome is the
|
||||
* most likely. Ideally, also collect performance numbers to justify the claim.
|
||||
*/
|
||||
|
|
|
@ -29,8 +29,7 @@ typedef struct {
|
|||
gpr_atm state;
|
||||
} gpr_event;
|
||||
|
||||
#define GPR_EVENT_INIT \
|
||||
{ 0 }
|
||||
#define GPR_EVENT_INIT {0}
|
||||
|
||||
/* gpr_refcount */
|
||||
typedef struct {
|
||||
|
@ -42,7 +41,6 @@ typedef struct {
|
|||
gpr_atm value;
|
||||
} gpr_stats_counter;
|
||||
|
||||
#define GPR_STATS_INIT \
|
||||
{ 0 }
|
||||
#define GPR_STATS_INIT {0}
|
||||
|
||||
#endif /* GRPC_SUPPORT_SYNC_GENERIC_H */
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
#ifndef GRPC_SUPPORT_SYNC_POSIX_H
|
||||
#define GRPC_SUPPORT_SYNC_POSIX_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpc/support/sync_generic.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifdef GRPC_ASAN_ENABLED
|
||||
/* The member |leak_checker| is used to check whether there is a memory leak
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#ifndef GRPC_SUPPORT_TIME_H
|
||||
#define GRPC_SUPPORT_TIME_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
* explanation and detailed descriptions of workarounds, see
|
||||
* /doc/workarounds.md
|
||||
*/
|
||||
typedef enum {
|
||||
GRPC_WORKAROUND_ID_CRONET_COMPRESSION = 0,
|
||||
GRPC_MAX_WORKAROUND_ID
|
||||
} grpc_workaround_list;
|
||||
typedef enum { GRPC_MAX_WORKAROUND_ID } grpc_workaround_list;
|
||||
|
||||
#endif /* GRPC_SUPPORT_WORKAROUND_LIST_H */
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef GRPCPP_ALARM_H
|
||||
#define GRPCPP_ALARM_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <grpc/event_engine/event_engine.h>
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpcpp/completion_queue.h>
|
||||
|
@ -30,6 +28,8 @@
|
|||
#include <grpcpp/impl/grpc_library.h>
|
||||
#include <grpcpp/support/time.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
/// Trigger a \a CompletionQueue event, or asynchronous callback execution,
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#ifndef GRPCPP_CHANNEL_H
|
||||
#define GRPCPP_CHANNEL_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpcpp/completion_queue.h>
|
||||
#include <grpcpp/impl/call.h>
|
||||
|
@ -30,6 +28,8 @@
|
|||
#include <grpcpp/support/client_interceptor.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
struct grpc_channel;
|
||||
|
||||
namespace grpc {
|
||||
|
|
|
@ -34,15 +34,8 @@
|
|||
#ifndef GRPCPP_CLIENT_CONTEXT_H
|
||||
#define GRPCPP_CLIENT_CONTEXT_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/impl/compression_types.h>
|
||||
#include <grpc/impl/propagation_bits.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/create_auth_context.h>
|
||||
#include <grpcpp/impl/metadata_map.h>
|
||||
#include <grpcpp/impl/rpc_method.h>
|
||||
|
@ -55,6 +48,12 @@
|
|||
#include <grpcpp/support/string_ref.h>
|
||||
#include <grpcpp/support/time.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
struct census_context;
|
||||
struct grpc_call;
|
||||
|
||||
|
@ -248,7 +247,7 @@ class ClientContext {
|
|||
/// \return A multimap of initial metadata key-value pairs from the server.
|
||||
const std::multimap<grpc::string_ref, grpc::string_ref>&
|
||||
GetServerInitialMetadata() const {
|
||||
CHECK(initial_metadata_received_);
|
||||
ABSL_CHECK(initial_metadata_received_);
|
||||
return *recv_initial_metadata_.map();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,21 +32,20 @@
|
|||
#ifndef GRPCPP_COMPLETION_QUEUE_H
|
||||
#define GRPCPP_COMPLETION_QUEUE_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/atm.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/time.h>
|
||||
#include <grpcpp/impl/codegen/rpc_service_method.h>
|
||||
#include <grpcpp/impl/codegen/status.h>
|
||||
#include <grpcpp/impl/codegen/sync.h>
|
||||
#include <grpcpp/impl/codegen/time.h>
|
||||
#include <grpcpp/impl/completion_queue_tag.h>
|
||||
#include <grpcpp/impl/grpc_library.h>
|
||||
#include <grpcpp/impl/sync.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
struct grpc_completion_queue;
|
||||
|
||||
|
@ -325,7 +324,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
|
|||
bool ok = ev.success != 0;
|
||||
void* ignored = tag;
|
||||
if (tag->FinalizeResult(&ignored, &ok)) {
|
||||
CHECK(ignored == tag);
|
||||
ABSL_CHECK(ignored == tag);
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +345,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
|
|||
bool ok = ev.success != 0;
|
||||
void* ignored = tag;
|
||||
// the tag must be swallowed if using TryPluck
|
||||
CHECK(!tag->FinalizeResult(&ignored, &ok));
|
||||
ABSL_CHECK(!tag->FinalizeResult(&ignored, &ok));
|
||||
}
|
||||
|
||||
/// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if
|
||||
|
@ -363,7 +362,7 @@ class CompletionQueue : private grpc::internal::GrpcLibrary {
|
|||
|
||||
bool ok = ev.success != 0;
|
||||
void* ignored = tag;
|
||||
CHECK(!tag->FinalizeResult(&ignored, &ok));
|
||||
ABSL_CHECK(!tag->FinalizeResult(&ignored, &ok));
|
||||
}
|
||||
|
||||
/// Manage state of avalanching operations : completion queue tags that
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
#ifndef GRPCPP_CREATE_CHANNEL_H
|
||||
#define GRPCPP_CREATE_CHANNEL_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/channel.h>
|
||||
#include <grpcpp/security/credentials.h>
|
||||
#include <grpcpp/support/channel_arguments.h>
|
||||
#include <grpcpp/support/client_interceptor.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
/// Create a new \a Channel pointing to \a target.
|
||||
///
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
// Copyright 2021 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef GRPCPP_CREATE_CHANNEL_BINDER_H
|
||||
#define GRPCPP_CREATE_CHANNEL_BINDER_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#ifdef GPR_ANDROID
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#include <grpcpp/channel.h>
|
||||
#include <grpcpp/security/binder_security_policy.h>
|
||||
#include <grpcpp/support/channel_arguments.h>
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
||||
/// EXPERIMENTAL Create a new \a Channel based on binder transport. The package
|
||||
/// name and class name will be used identify the specific application component
|
||||
/// to connect to.
|
||||
///
|
||||
/// \param jni_env_void Pointer to a JNIEnv structure
|
||||
/// \param context The context that we will use to invoke \a bindService See
|
||||
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
|
||||
/// for detail.
|
||||
/// \param package_name Package name of the component to be connected to
|
||||
/// \param class_name Class name of the component to be connected to
|
||||
/// \param security_policy Used for checking if remote component is allowed to
|
||||
/// connect
|
||||
std::shared_ptr<grpc::Channel> CreateBinderChannel(
|
||||
void* jni_env_void, jobject context, absl::string_view package_name,
|
||||
absl::string_view class_name,
|
||||
std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
|
||||
security_policy);
|
||||
|
||||
/// EXPERIMENTAL Create a new \a Channel based on binder transport. The package
|
||||
/// name and class name will be used identify the specific application component
|
||||
/// to connect to.
|
||||
///
|
||||
/// \param jni_env_void Pointer to a JNIEnv structure
|
||||
/// \param context The context that we will use to invoke \a bindService See
|
||||
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
|
||||
/// for detail.
|
||||
/// \param package_name Package name of the component to be connected to
|
||||
/// \param class_name Class name of the component to be connected to
|
||||
/// \param security_policy Used for checking if remote component is allowed to
|
||||
/// connect
|
||||
/// \param args Options for channel creation.
|
||||
std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
|
||||
void* jni_env_void, jobject context, absl::string_view package_name,
|
||||
absl::string_view class_name,
|
||||
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> security_policy,
|
||||
const ChannelArguments& args);
|
||||
|
||||
/// EXPERIMENTAL Create a new \a Channel based on binder transport.
|
||||
///
|
||||
/// \param jni_env_void Pointer to a JNIEnv structure
|
||||
/// \param context The context that we will use to invoke \a bindService See
|
||||
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
|
||||
/// for detail.
|
||||
/// \param uri An URI that can be parsed as an `Intent` with
|
||||
/// https://developer.android.com/reference/android/content/Intent#parseUri(java.lang.String,%20int)
|
||||
/// \param security_policy Used for checking if remote component is allowed to
|
||||
/// connect
|
||||
std::shared_ptr<grpc::Channel> CreateBinderChannel(
|
||||
void* jni_env_void, jobject context, absl::string_view uri,
|
||||
std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
|
||||
security_policy);
|
||||
|
||||
/// EXPERIMENTAL Create a new \a Channel based on binder transport.
|
||||
///
|
||||
/// \param jni_env_void Pointer to a JNIEnv structure
|
||||
/// \param context The context that we will use to invoke \a bindService See
|
||||
/// https://developer.android.com/reference/android/content/Context#bindService(android.content.Intent,%20android.content.ServiceConnection,%20int)
|
||||
/// for detail.
|
||||
/// \param uri An URI that can be parsed as an `Intent` with
|
||||
/// https://developer.android.com/reference/android/content/Intent#parseUri(java.lang.String,%20int)
|
||||
/// \param security_policy Used for checking if remote component is allowed to
|
||||
/// connect
|
||||
/// \param args Options for channel creation.
|
||||
std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
|
||||
void* jni_env_void, jobject context, absl::string_view uri,
|
||||
std::shared_ptr<grpc::experimental::binder::SecurityPolicy> security_policy,
|
||||
const ChannelArguments& args);
|
||||
|
||||
/// EXPERIMENTAL Finds internal binder transport Java code. To create channels
|
||||
/// in threads created in native code, it is required to call this function
|
||||
/// once beforehand in a thread that is not created in native code.
|
||||
/// See
|
||||
/// https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class
|
||||
/// for details of this limitation.
|
||||
/// Returns true when the initialization is successful.
|
||||
bool InitializeBinderChannelJavaClass(void* jni_env_void);
|
||||
|
||||
/// EXPERIMENTAL Alternative version of `InitializeBinderChannelJavaClass(void*
|
||||
/// jni_env_void)`. This version used a user-specified function to find the
|
||||
/// required internal Java class. When a class is found, the `class_finder`
|
||||
/// function should return a local reference to the class (jclass type). The
|
||||
/// returned jclass will then be used to create global reference for gRPC to use
|
||||
/// it later. After that, gRPC will DeleteLocalRef the returned local reference.
|
||||
bool InitializeBinderChannelJavaClass(
|
||||
void* jni_env_void, std::function<void*(std::string)> class_finder);
|
||||
|
||||
} // namespace experimental
|
||||
} // namespace grpc
|
||||
|
||||
#endif
|
||||
|
||||
#endif // GRPCPP_CREATE_CHANNEL_BINDER_H
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef GRPCPP_CREATE_CHANNEL_POSIX_H
|
||||
#define GRPCPP_CREATE_CHANNEL_POSIX_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpcpp/channel.h>
|
||||
#include <grpcpp/support/channel_arguments.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD
|
||||
|
|
|
@ -19,21 +19,20 @@
|
|||
#ifndef GRPCPP_EXT_CALL_METRIC_RECORDER_H
|
||||
#define GRPCPP_EXT_CALL_METRIC_RECORDER_H
|
||||
|
||||
#include <grpcpp/impl/sync.h>
|
||||
#include <grpcpp/support/slice.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
#include <grpcpp/impl/sync.h>
|
||||
#include <grpcpp/support/slice.h>
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
||||
/// Records call metrics for the purpose of load balancing.
|
||||
/// During an RPC, call \a ServerContext::ExperimentalGetCallMetricRecorder()
|
||||
/// method to retrive the recorder for the current call.
|
||||
/// method to retrieve the recorder for the current call.
|
||||
class CallMetricRecorder {
|
||||
public:
|
||||
virtual ~CallMetricRecorder() = default;
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef GRPCPP_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H
|
||||
#define GRPCPP_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/health_check_service_interface.h>
|
||||
#include <grpcpp/impl/server_builder_option.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class HealthCheckServiceServerBuilderOption : public ServerBuilderOption {
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
#ifndef GRPCPP_EXT_SERVER_METRIC_RECORDER_H
|
||||
#define GRPCPP_EXT_SERVER_METRIC_RECORDER_H
|
||||
|
||||
#include <grpcpp/impl/sync.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/impl/sync.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
namespace grpc_core {
|
||||
struct BackendMetricData;
|
||||
} // namespace grpc_core
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
#define GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpcpp/impl/server_callback_handlers.h>
|
||||
#include <grpcpp/generic/callback_generic_service.h>
|
||||
#include <grpcpp/support/async_stream.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/server_callback.h>
|
||||
|
||||
struct grpc_server;
|
||||
|
||||
|
@ -78,57 +77,6 @@ class AsyncGenericService final {
|
|||
grpc::Server* server_;
|
||||
};
|
||||
|
||||
/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs
|
||||
/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with
|
||||
/// ByteBuffer arguments.
|
||||
using ServerGenericBidiReactor = ServerBidiReactor<ByteBuffer, ByteBuffer>;
|
||||
|
||||
class GenericCallbackServerContext final : public grpc::CallbackServerContext {
|
||||
public:
|
||||
const std::string& method() const { return method_; }
|
||||
const std::string& host() const { return host_; }
|
||||
|
||||
private:
|
||||
friend class grpc::Server;
|
||||
|
||||
std::string method_;
|
||||
std::string host_;
|
||||
};
|
||||
|
||||
/// \a CallbackGenericService is the base class for generic services implemented
|
||||
/// using the callback API and registered through the ServerBuilder using
|
||||
/// RegisterCallbackGenericService.
|
||||
class CallbackGenericService {
|
||||
public:
|
||||
CallbackGenericService() {}
|
||||
virtual ~CallbackGenericService() {}
|
||||
|
||||
/// The "method handler" for the generic API. This function should be
|
||||
/// overridden to provide a ServerGenericBidiReactor that implements the
|
||||
/// application-level interface for this RPC. Unimplemented by default.
|
||||
virtual ServerGenericBidiReactor* CreateReactor(
|
||||
GenericCallbackServerContext* /*ctx*/) {
|
||||
class Reactor : public ServerGenericBidiReactor {
|
||||
public:
|
||||
Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); }
|
||||
void OnDone() override { delete this; }
|
||||
};
|
||||
return new Reactor;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class grpc::Server;
|
||||
|
||||
internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>* Handler() {
|
||||
return new internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>(
|
||||
[this](grpc::CallbackServerContext* ctx) {
|
||||
return CreateReactor(static_cast<GenericCallbackServerContext*>(ctx));
|
||||
});
|
||||
}
|
||||
|
||||
grpc::Server* server_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_GENERIC_ASYNC_GENERIC_SERVICE_H
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
//
|
||||
//
|
||||
// Copyright 2024 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
|
||||
#define GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpcpp/impl/server_callback_handlers.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/server_callback.h>
|
||||
|
||||
struct grpc_server;
|
||||
|
||||
namespace grpc {
|
||||
|
||||
/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs
|
||||
/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with
|
||||
/// ByteBuffer arguments.
|
||||
using ServerGenericBidiReactor = ServerBidiReactor<ByteBuffer, ByteBuffer>;
|
||||
|
||||
class GenericCallbackServerContext final : public grpc::CallbackServerContext {
|
||||
public:
|
||||
const std::string& method() const { return method_; }
|
||||
const std::string& host() const { return host_; }
|
||||
|
||||
private:
|
||||
friend class grpc::Server;
|
||||
|
||||
std::string method_;
|
||||
std::string host_;
|
||||
};
|
||||
|
||||
/// \a CallbackGenericService is the base class for generic services implemented
|
||||
/// using the callback API and registered through the ServerBuilder using
|
||||
/// RegisterCallbackGenericService.
|
||||
class CallbackGenericService {
|
||||
public:
|
||||
CallbackGenericService() {}
|
||||
virtual ~CallbackGenericService() {}
|
||||
|
||||
/// The "method handler" for the generic API. This function should be
|
||||
/// overridden to provide a ServerGenericBidiReactor that implements the
|
||||
/// application-level interface for this RPC. Unimplemented by default.
|
||||
virtual ServerGenericBidiReactor* CreateReactor(
|
||||
GenericCallbackServerContext* /*ctx*/) {
|
||||
class Reactor : public ServerGenericBidiReactor {
|
||||
public:
|
||||
Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); }
|
||||
void OnDone() override { delete this; }
|
||||
};
|
||||
return new Reactor;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class grpc::Server;
|
||||
|
||||
internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>* Handler() {
|
||||
return new internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>(
|
||||
[this](grpc::CallbackServerContext* ctx) {
|
||||
return CreateReactor(static_cast<GenericCallbackServerContext*>(ctx));
|
||||
});
|
||||
}
|
||||
|
||||
grpc::Server* server_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_GENERIC_CALLBACK_GENERIC_SERVICE_H
|
|
@ -19,15 +19,12 @@
|
|||
#ifndef GRPCPP_GENERIC_GENERIC_STUB_H
|
||||
#define GRPCPP_GENERIC_GENERIC_STUB_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <grpcpp/client_context.h>
|
||||
#include <grpcpp/impl/generic_stub_internal.h>
|
||||
#include <grpcpp/impl/rpc_method.h>
|
||||
#include <grpcpp/support/async_stream.h>
|
||||
#include <grpcpp/support/async_unary_call.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/client_callback.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
#include <grpcpp/support/stub_options.h>
|
||||
|
||||
namespace grpc {
|
||||
|
@ -42,10 +39,12 @@ typedef ClientAsyncResponseReader<ByteBuffer> GenericClientAsyncResponseReader;
|
|||
/// by name. In practice, the Request and Response types should be basic
|
||||
/// types like grpc::ByteBuffer or proto::MessageLite (the base protobuf).
|
||||
template <class RequestType, class ResponseType>
|
||||
class TemplatedGenericStub final {
|
||||
class TemplatedGenericStub final
|
||||
: public internal::TemplatedGenericStubCallbackInternal<RequestType,
|
||||
ResponseType> {
|
||||
public:
|
||||
explicit TemplatedGenericStub(std::shared_ptr<grpc::ChannelInterface> channel)
|
||||
: channel_(channel) {}
|
||||
using internal::TemplatedGenericStubCallbackInternal<
|
||||
RequestType, ResponseType>::TemplatedGenericStubCallbackInternal;
|
||||
|
||||
/// Setup a call to a named method \a method using \a context, but don't
|
||||
/// start it. Let it be started explicitly with StartCall and a tag.
|
||||
|
@ -74,6 +73,9 @@ class TemplatedGenericStub final {
|
|||
context, request));
|
||||
}
|
||||
|
||||
using internal::TemplatedGenericStubCallbackInternal<
|
||||
RequestType, ResponseType>::PrepareUnaryCall;
|
||||
|
||||
/// DEPRECATED for multi-threaded use
|
||||
/// Begin a call to a named method \a method using \a context.
|
||||
/// A tag \a tag will be delivered to \a cq when the call has been started
|
||||
|
@ -87,72 +89,9 @@ class TemplatedGenericStub final {
|
|||
true, tag);
|
||||
}
|
||||
|
||||
/// Setup and start a unary call to a named method \a method using
|
||||
/// \a context and specifying the \a request and \a response buffers.
|
||||
void UnaryCall(ClientContext* context, const std::string& method,
|
||||
StubOptions options, const RequestType* request,
|
||||
ResponseType* response,
|
||||
std::function<void(grpc::Status)> on_completion) {
|
||||
UnaryCallInternal(context, method, options, request, response,
|
||||
std::move(on_completion));
|
||||
}
|
||||
|
||||
/// Setup a unary call to a named method \a method using
|
||||
/// \a context and specifying the \a request and \a response buffers.
|
||||
/// Like any other reactor-based RPC, it will not be activated until
|
||||
/// StartCall is invoked on its reactor.
|
||||
void PrepareUnaryCall(ClientContext* context, const std::string& method,
|
||||
StubOptions options, const RequestType* request,
|
||||
ResponseType* response, ClientUnaryReactor* reactor) {
|
||||
PrepareUnaryCallInternal(context, method, options, request, response,
|
||||
reactor);
|
||||
}
|
||||
|
||||
/// Setup a call to a named method \a method using \a context and tied to
|
||||
/// \a reactor . Like any other bidi streaming RPC, it will not be activated
|
||||
/// until StartCall is invoked on its reactor.
|
||||
void PrepareBidiStreamingCall(
|
||||
ClientContext* context, const std::string& method, StubOptions options,
|
||||
ClientBidiReactor<RequestType, ResponseType>* reactor) {
|
||||
PrepareBidiStreamingCallInternal(context, method, options, reactor);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<grpc::ChannelInterface> channel_;
|
||||
|
||||
void UnaryCallInternal(ClientContext* context, const std::string& method,
|
||||
StubOptions options, const RequestType* request,
|
||||
ResponseType* response,
|
||||
std::function<void(grpc::Status)> on_completion) {
|
||||
internal::CallbackUnaryCall(
|
||||
channel_.get(),
|
||||
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
|
||||
grpc::internal::RpcMethod::NORMAL_RPC),
|
||||
context, request, response, std::move(on_completion));
|
||||
}
|
||||
|
||||
void PrepareUnaryCallInternal(ClientContext* context,
|
||||
const std::string& method, StubOptions options,
|
||||
const RequestType* request,
|
||||
ResponseType* response,
|
||||
ClientUnaryReactor* reactor) {
|
||||
internal::ClientCallbackUnaryFactory::Create<RequestType, ResponseType>(
|
||||
channel_.get(),
|
||||
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
|
||||
grpc::internal::RpcMethod::NORMAL_RPC),
|
||||
context, request, response, reactor);
|
||||
}
|
||||
|
||||
void PrepareBidiStreamingCallInternal(
|
||||
ClientContext* context, const std::string& method, StubOptions options,
|
||||
ClientBidiReactor<RequestType, ResponseType>* reactor) {
|
||||
internal::ClientCallbackReaderWriterFactory<RequestType, ResponseType>::
|
||||
Create(channel_.get(),
|
||||
grpc::internal::RpcMethod(
|
||||
method.c_str(), options.suffix_for_stats(),
|
||||
grpc::internal::RpcMethod::BIDI_STREAMING),
|
||||
context, reactor);
|
||||
}
|
||||
using internal::TemplatedGenericStubCallbackInternal<RequestType,
|
||||
ResponseType>::channel_;
|
||||
|
||||
std::unique_ptr<ClientAsyncReaderWriter<RequestType, ResponseType>>
|
||||
CallInternal(grpc::ChannelInterface* channel, ClientContext* context,
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
//
|
||||
// Copyright 2024 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef GRPCPP_GENERIC_GENERIC_STUB_CALLBACK_H
|
||||
#define GRPCPP_GENERIC_GENERIC_STUB_CALLBACK_H
|
||||
|
||||
#include <grpcpp/impl/generic_stub_internal.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
/// Generic stubs provide a type-unaware interface to call gRPC methods
|
||||
/// by name. In practice, the Request and Response types should be basic
|
||||
/// types like grpc::ByteBuffer or proto::MessageLite (the base protobuf).
|
||||
template <class RequestType, class ResponseType>
|
||||
class TemplatedGenericStubCallback final
|
||||
: public internal::TemplatedGenericStubCallbackInternal<RequestType,
|
||||
ResponseType> {
|
||||
public:
|
||||
using internal::TemplatedGenericStubCallbackInternal<
|
||||
RequestType, ResponseType>::TemplatedGenericStubCallbackInternal;
|
||||
};
|
||||
|
||||
typedef TemplatedGenericStubCallback<grpc::ByteBuffer, grpc::ByteBuffer>
|
||||
GenericStubCallback;
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_GENERIC_GENERIC_STUB_CALLBACK_H
|
|
@ -19,18 +19,11 @@
|
|||
#ifndef GRPCPP_IMPL_CALL_OP_SET_H
|
||||
#define GRPCPP_IMPL_CALL_OP_SET_H
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/impl/compression_types.h>
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/client_context.h>
|
||||
#include <grpcpp/completion_queue.h>
|
||||
#include <grpcpp/impl/call.h>
|
||||
|
@ -45,6 +38,13 @@
|
|||
#include <grpcpp/support/slice.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
#include "absl/log/absl_log.h"
|
||||
|
||||
namespace grpc {
|
||||
|
||||
namespace internal {
|
||||
|
@ -318,7 +318,7 @@ class CallOpSendMessage {
|
|||
return;
|
||||
}
|
||||
if (msg_ != nullptr) {
|
||||
CHECK(serializer_(msg_).ok());
|
||||
ABSL_CHECK(serializer_(msg_).ok());
|
||||
}
|
||||
serializer_ = nullptr;
|
||||
grpc_op* op = &ops[(*nops)++];
|
||||
|
@ -771,7 +771,9 @@ class CallOpRecvInitialMetadata {
|
|||
class CallOpClientRecvStatus {
|
||||
public:
|
||||
CallOpClientRecvStatus()
|
||||
: recv_status_(nullptr), debug_error_string_(nullptr) {}
|
||||
: metadata_map_(nullptr),
|
||||
recv_status_(nullptr),
|
||||
debug_error_string_(nullptr) {}
|
||||
|
||||
void ClientRecvStatus(grpc::ClientContext* context, Status* status) {
|
||||
client_context_ = context;
|
||||
|
@ -797,7 +799,7 @@ class CallOpClientRecvStatus {
|
|||
if (recv_status_ == nullptr || hijacked_) return;
|
||||
if (static_cast<StatusCode>(status_code_) == StatusCode::OK) {
|
||||
*recv_status_ = Status();
|
||||
DCHECK_EQ(debug_error_string_, nullptr);
|
||||
ABSL_DCHECK_EQ(debug_error_string_, nullptr);
|
||||
} else {
|
||||
*recv_status_ =
|
||||
Status(static_cast<StatusCode>(status_code_),
|
||||
|
@ -974,9 +976,9 @@ class CallOpSet : public CallOpSetInterface,
|
|||
// A failure here indicates an API misuse; for example, doing a Write
|
||||
// while another Write is already pending on the same RPC or invoking
|
||||
// WritesDone multiple times
|
||||
gpr_log(GPR_ERROR, "API misuse of type %s observed",
|
||||
grpc_call_error_to_string(err));
|
||||
CHECK(false);
|
||||
ABSL_LOG(ERROR) << "API misuse of type " << grpc_call_error_to_string(err)
|
||||
<< " observed";
|
||||
ABSL_CHECK(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,8 +988,8 @@ class CallOpSet : public CallOpSetInterface,
|
|||
done_intercepting_ = true;
|
||||
// The following call_start_batch is internally-generated so no need for an
|
||||
// explanatory log on failure.
|
||||
CHECK(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(),
|
||||
nullptr) == GRPC_CALL_OK);
|
||||
ABSL_CHECK(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(),
|
||||
nullptr) == GRPC_CALL_OK);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef GRPCPP_IMPL_CHANNEL_ARGUMENT_OPTION_H
|
||||
#define GRPCPP_IMPL_CHANNEL_ARGUMENT_OPTION_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/impl/server_builder_option.h>
|
||||
#include <grpcpp/support/channel_arguments.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
// IWYU pragma: private
|
||||
|
||||
#define GRPC_OPEN_SOURCE_PROTO
|
||||
// #define GRPC_OPEN_SOURCE_PROTO
|
||||
|
||||
#define GRPC_PROTOBUF_CORD_SUPPORT_ENABLED
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
|||
#ifndef GRPC_CUSTOM_DESCRIPTOR
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#if GOOGLE_PROTOBUF_VERSION >= 4025000
|
||||
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 4025000
|
||||
#define GRPC_PROTOBUF_EDITION_SUPPORT
|
||||
#endif
|
||||
#define GRPC_CUSTOM_DESCRIPTOR ::google::protobuf::Descriptor
|
||||
|
@ -71,6 +71,7 @@
|
|||
#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \
|
||||
::google::protobuf::io::ZeroCopyInputStream
|
||||
#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream
|
||||
#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream
|
||||
#endif
|
||||
|
||||
#ifndef GRPC_CUSTOM_JSONUTIL
|
||||
|
@ -113,6 +114,7 @@ namespace io {
|
|||
typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream;
|
||||
typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream;
|
||||
typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream;
|
||||
typedef GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream;
|
||||
} // namespace io
|
||||
|
||||
} // namespace protobuf
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef GRPCPP_IMPL_CREATE_AUTH_CONTEXT_H
|
||||
#define GRPCPP_IMPL_CREATE_AUTH_CONTEXT_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpcpp/security/auth_context.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
/// TODO(ctiller): not sure we want to make this a permanent thing
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
#ifndef GRPCPP_IMPL_DELEGATING_CHANNEL_H
|
||||
#define GRPCPP_IMPL_DELEGATING_CHANNEL_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/impl/channel_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
// Copyright 2024 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef GRPCPP_IMPL_GENERIC_SERIALIZE_H
|
||||
#define GRPCPP_IMPL_GENERIC_SERIALIZE_H
|
||||
|
||||
#include <grpc/byte_buffer_reader.h>
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpcpp/impl/codegen/config_protobuf.h>
|
||||
#include <grpcpp/impl/serialization_traits.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/proto_buffer_reader.h>
|
||||
#include <grpcpp/support/proto_buffer_writer.h>
|
||||
#include <grpcpp/support/slice.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
/// This header provides serialization and deserialization between gRPC
|
||||
/// messages serialized using protobuf and the C++ objects they represent.
|
||||
|
||||
namespace grpc {
|
||||
|
||||
// ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream.
|
||||
template <class ProtoBufferWriter, class T>
|
||||
Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb,
|
||||
bool* own_buffer) {
|
||||
static_assert(std::is_base_of<protobuf::io::ZeroCopyOutputStream,
|
||||
ProtoBufferWriter>::value,
|
||||
"ProtoBufferWriter must be a subclass of "
|
||||
"::protobuf::io::ZeroCopyOutputStream");
|
||||
*own_buffer = true;
|
||||
int byte_size = static_cast<int>(msg.ByteSizeLong());
|
||||
if (static_cast<size_t>(byte_size) <= GRPC_SLICE_INLINED_SIZE) {
|
||||
Slice slice(byte_size);
|
||||
// We serialize directly into the allocated slices memory
|
||||
ABSL_CHECK(slice.end() == msg.SerializeWithCachedSizesToArray(
|
||||
const_cast<uint8_t*>(slice.begin())));
|
||||
ByteBuffer tmp(&slice, 1);
|
||||
bb->Swap(&tmp);
|
||||
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
ProtoBufferWriter writer(bb, kProtoBufferWriterMaxBufferLength, byte_size);
|
||||
protobuf::io::CodedOutputStream cs(&writer);
|
||||
msg.SerializeWithCachedSizes(&cs);
|
||||
return !cs.HadError()
|
||||
? grpc::Status::OK
|
||||
: Status(StatusCode::INTERNAL, "Failed to serialize message");
|
||||
}
|
||||
|
||||
// BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream.
|
||||
template <class ProtoBufferReader, class T>
|
||||
Status GenericDeserialize(ByteBuffer* buffer,
|
||||
grpc::protobuf::MessageLite* msg) {
|
||||
static_assert(std::is_base_of<protobuf::io::ZeroCopyInputStream,
|
||||
ProtoBufferReader>::value,
|
||||
"ProtoBufferReader must be a subclass of "
|
||||
"::protobuf::io::ZeroCopyInputStream");
|
||||
if (buffer == nullptr) {
|
||||
return Status(StatusCode::INTERNAL, "No payload");
|
||||
}
|
||||
Status result = grpc::Status::OK;
|
||||
{
|
||||
ProtoBufferReader reader(buffer);
|
||||
if (!reader.status().ok()) {
|
||||
return reader.status();
|
||||
}
|
||||
if (!msg->ParseFromZeroCopyStream(&reader)) {
|
||||
result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
|
||||
}
|
||||
}
|
||||
buffer->Clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_IMPL_GENERIC_SERIALIZE_H
|
|
@ -0,0 +1,125 @@
|
|||
//
|
||||
//
|
||||
// Copyright 2024 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef GRPCPP_IMPL_GENERIC_STUB_INTERNAL_H
|
||||
#define GRPCPP_IMPL_GENERIC_STUB_INTERNAL_H
|
||||
|
||||
#include <grpcpp/client_context.h>
|
||||
#include <grpcpp/impl/rpc_method.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/client_callback.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
#include <grpcpp/support/stub_options.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
template <class RequestType, class ResponseType>
|
||||
class TemplatedGenericStub;
|
||||
template <class RequestType, class ResponseType>
|
||||
class TemplatedGenericStubCallback;
|
||||
|
||||
namespace internal {
|
||||
|
||||
/// Generic stubs provide a type-unaware interface to call gRPC methods
|
||||
/// by name. In practice, the Request and Response types should be basic
|
||||
/// types like grpc::ByteBuffer or proto::MessageLite (the base protobuf).
|
||||
template <class RequestType, class ResponseType>
|
||||
class TemplatedGenericStubCallbackInternal {
|
||||
public:
|
||||
explicit TemplatedGenericStubCallbackInternal(
|
||||
std::shared_ptr<grpc::ChannelInterface> channel)
|
||||
: channel_(channel) {}
|
||||
|
||||
/// Setup and start a unary call to a named method \a method using
|
||||
/// \a context and specifying the \a request and \a response buffers.
|
||||
void UnaryCall(ClientContext* context, const std::string& method,
|
||||
StubOptions options, const RequestType* request,
|
||||
ResponseType* response,
|
||||
std::function<void(grpc::Status)> on_completion) {
|
||||
UnaryCallInternal(context, method, options, request, response,
|
||||
std::move(on_completion));
|
||||
}
|
||||
|
||||
/// Setup a unary call to a named method \a method using
|
||||
/// \a context and specifying the \a request and \a response buffers.
|
||||
/// Like any other reactor-based RPC, it will not be activated until
|
||||
/// StartCall is invoked on its reactor.
|
||||
void PrepareUnaryCall(ClientContext* context, const std::string& method,
|
||||
StubOptions options, const RequestType* request,
|
||||
ResponseType* response, ClientUnaryReactor* reactor) {
|
||||
PrepareUnaryCallInternal(context, method, options, request, response,
|
||||
reactor);
|
||||
}
|
||||
|
||||
/// Setup a call to a named method \a method using \a context and tied to
|
||||
/// \a reactor . Like any other bidi streaming RPC, it will not be activated
|
||||
/// until StartCall is invoked on its reactor.
|
||||
void PrepareBidiStreamingCall(
|
||||
ClientContext* context, const std::string& method, StubOptions options,
|
||||
ClientBidiReactor<RequestType, ResponseType>* reactor) {
|
||||
PrepareBidiStreamingCallInternal(context, method, options, reactor);
|
||||
}
|
||||
|
||||
private:
|
||||
template <class Req, class Resp>
|
||||
friend class grpc::TemplatedGenericStub;
|
||||
template <class Req, class Resp>
|
||||
friend class grpc::TemplatedGenericStubCallback;
|
||||
std::shared_ptr<grpc::ChannelInterface> channel_;
|
||||
|
||||
void UnaryCallInternal(ClientContext* context, const std::string& method,
|
||||
StubOptions options, const RequestType* request,
|
||||
ResponseType* response,
|
||||
std::function<void(grpc::Status)> on_completion) {
|
||||
internal::CallbackUnaryCall(
|
||||
channel_.get(),
|
||||
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
|
||||
grpc::internal::RpcMethod::NORMAL_RPC),
|
||||
context, request, response, std::move(on_completion));
|
||||
}
|
||||
|
||||
void PrepareUnaryCallInternal(ClientContext* context,
|
||||
const std::string& method, StubOptions options,
|
||||
const RequestType* request,
|
||||
ResponseType* response,
|
||||
ClientUnaryReactor* reactor) {
|
||||
internal::ClientCallbackUnaryFactory::Create<RequestType, ResponseType>(
|
||||
channel_.get(),
|
||||
grpc::internal::RpcMethod(method.c_str(), options.suffix_for_stats(),
|
||||
grpc::internal::RpcMethod::NORMAL_RPC),
|
||||
context, request, response, reactor);
|
||||
}
|
||||
|
||||
void PrepareBidiStreamingCallInternal(
|
||||
ClientContext* context, const std::string& method, StubOptions options,
|
||||
ClientBidiReactor<RequestType, ResponseType>* reactor) {
|
||||
internal::ClientCallbackReaderWriterFactory<RequestType, ResponseType>::
|
||||
Create(channel_.get(),
|
||||
grpc::internal::RpcMethod(
|
||||
method.c_str(), options.suffix_for_stats(),
|
||||
grpc::internal::RpcMethod::BIDI_STREAMING),
|
||||
context, reactor);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_IMPL_GENERIC_STUB_INTERNAL_H
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef GRPCPP_IMPL_GRPC_LIBRARY_H
|
||||
#define GRPCPP_IMPL_GRPC_LIBRARY_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpcpp/impl/codegen/config.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
namespace internal {
|
||||
|
|
|
@ -19,19 +19,18 @@
|
|||
#ifndef GRPCPP_IMPL_INTERCEPTOR_COMMON_H
|
||||
#define GRPCPP_IMPL_INTERCEPTOR_COMMON_H
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/call.h>
|
||||
#include <grpcpp/impl/call_op_set_interface.h>
|
||||
#include <grpcpp/impl/intercepted_channel.h>
|
||||
#include <grpcpp/support/client_interceptor.h>
|
||||
#include <grpcpp/support/server_interceptor.h>
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
namespace grpc {
|
||||
namespace internal {
|
||||
|
||||
|
@ -58,15 +57,16 @@ class InterceptorBatchMethodsImpl
|
|||
if (call_->client_rpc_info() != nullptr) {
|
||||
return ProceedClient();
|
||||
}
|
||||
CHECK_NE(call_->server_rpc_info(), nullptr);
|
||||
ABSL_CHECK_NE(call_->server_rpc_info(), nullptr);
|
||||
ProceedServer();
|
||||
}
|
||||
|
||||
void Hijack() override {
|
||||
// Only the client can hijack when sending down initial metadata
|
||||
CHECK(!reverse_ && ops_ != nullptr && call_->client_rpc_info() != nullptr);
|
||||
ABSL_CHECK(!reverse_ && ops_ != nullptr &&
|
||||
call_->client_rpc_info() != nullptr);
|
||||
// It is illegal to call Hijack twice
|
||||
CHECK(!ran_hijacking_interceptor_);
|
||||
ABSL_CHECK(!ran_hijacking_interceptor_);
|
||||
auto* rpc_info = call_->client_rpc_info();
|
||||
rpc_info->hijacked_ = true;
|
||||
rpc_info->hijacked_interceptor_ = current_interceptor_index_;
|
||||
|
@ -81,21 +81,21 @@ class InterceptorBatchMethodsImpl
|
|||
}
|
||||
|
||||
ByteBuffer* GetSerializedSendMessage() override {
|
||||
CHECK_NE(orig_send_message_, nullptr);
|
||||
ABSL_CHECK_NE(orig_send_message_, nullptr);
|
||||
if (*orig_send_message_ != nullptr) {
|
||||
CHECK(serializer_(*orig_send_message_).ok());
|
||||
ABSL_CHECK(serializer_(*orig_send_message_).ok());
|
||||
*orig_send_message_ = nullptr;
|
||||
}
|
||||
return send_message_;
|
||||
}
|
||||
|
||||
const void* GetSendMessage() override {
|
||||
CHECK_NE(orig_send_message_, nullptr);
|
||||
ABSL_CHECK_NE(orig_send_message_, nullptr);
|
||||
return *orig_send_message_;
|
||||
}
|
||||
|
||||
void ModifySendMessage(const void* message) override {
|
||||
CHECK_NE(orig_send_message_, nullptr);
|
||||
ABSL_CHECK_NE(orig_send_message_, nullptr);
|
||||
*orig_send_message_ = message;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ class InterceptorBatchMethodsImpl
|
|||
Status* GetRecvStatus() override { return recv_status_; }
|
||||
|
||||
void FailHijackedSendMessage() override {
|
||||
CHECK(hooks_[static_cast<size_t>(
|
||||
ABSL_CHECK(hooks_[static_cast<size_t>(
|
||||
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)]);
|
||||
*fail_send_message_ = true;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class InterceptorBatchMethodsImpl
|
|||
}
|
||||
|
||||
void FailHijackedRecvMessage() override {
|
||||
CHECK(hooks_[static_cast<size_t>(
|
||||
ABSL_CHECK(hooks_[static_cast<size_t>(
|
||||
experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)]);
|
||||
*hijacked_recv_message_failed_ = true;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class InterceptorBatchMethodsImpl
|
|||
// ContinueFinalizeOpsAfterInterception will be called. Note that neither of
|
||||
// them is invoked if there were no interceptors registered.
|
||||
bool RunInterceptors() {
|
||||
CHECK(ops_);
|
||||
ABSL_CHECK(ops_);
|
||||
auto* client_rpc_info = call_->client_rpc_info();
|
||||
if (client_rpc_info != nullptr) {
|
||||
if (client_rpc_info->interceptors_.empty()) {
|
||||
|
@ -262,8 +262,8 @@ class InterceptorBatchMethodsImpl
|
|||
// SyncRequest.
|
||||
bool RunInterceptors(std::function<void(void)> f) {
|
||||
// This is used only by the server for initial call request
|
||||
CHECK_EQ(reverse_, true);
|
||||
CHECK_EQ(call_->client_rpc_info(), nullptr);
|
||||
ABSL_CHECK_EQ(reverse_, true);
|
||||
ABSL_CHECK_EQ(call_->client_rpc_info(), nullptr);
|
||||
auto* server_rpc_info = call_->server_rpc_info();
|
||||
if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) {
|
||||
return true;
|
||||
|
@ -357,7 +357,7 @@ class InterceptorBatchMethodsImpl
|
|||
return ops_->ContinueFinalizeResultAfterInterception();
|
||||
}
|
||||
}
|
||||
CHECK(callback_);
|
||||
ABSL_CHECK(callback_);
|
||||
callback_();
|
||||
}
|
||||
|
||||
|
@ -423,98 +423,103 @@ class CancelInterceptorBatchMethods
|
|||
|
||||
void Hijack() override {
|
||||
// Only the client can hijack when sending down initial metadata
|
||||
CHECK(false) << "It is illegal to call Hijack on a method which has a "
|
||||
"Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call Hijack on a method which has a "
|
||||
"Cancel notification";
|
||||
}
|
||||
|
||||
ByteBuffer* GetSerializedSendMessage() override {
|
||||
CHECK(false) << "It is illegal to call GetSendMessage on a method which "
|
||||
"has a Cancel notification";
|
||||
ABSL_CHECK(false)
|
||||
<< "It is illegal to call GetSendMessage on a method which "
|
||||
"has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool GetSendMessageStatus() override {
|
||||
CHECK(false)
|
||||
ABSL_CHECK(false)
|
||||
<< "It is illegal to call GetSendMessageStatus on a method which "
|
||||
"has a Cancel notification";
|
||||
return false;
|
||||
}
|
||||
|
||||
const void* GetSendMessage() override {
|
||||
CHECK(false)
|
||||
ABSL_CHECK(false)
|
||||
<< "It is illegal to call GetOriginalSendMessage on a method which "
|
||||
"has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ModifySendMessage(const void* /*message*/) override {
|
||||
CHECK(false) << "It is illegal to call ModifySendMessage on a method which "
|
||||
"has a Cancel notification";
|
||||
ABSL_CHECK(false)
|
||||
<< "It is illegal to call ModifySendMessage on a method which "
|
||||
"has a Cancel notification";
|
||||
}
|
||||
|
||||
std::multimap<std::string, std::string>* GetSendInitialMetadata() override {
|
||||
CHECK(false) << "It is illegal to call GetSendInitialMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call GetSendInitialMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Status GetSendStatus() override {
|
||||
CHECK(false) << "It is illegal to call GetSendStatus on a method which "
|
||||
"has a Cancel notification";
|
||||
ABSL_CHECK(false)
|
||||
<< "It is illegal to call GetSendStatus on a method which "
|
||||
"has a Cancel notification";
|
||||
return Status();
|
||||
}
|
||||
|
||||
void ModifySendStatus(const Status& /*status*/) override {
|
||||
CHECK(false) << "It is illegal to call ModifySendStatus on a method "
|
||||
"which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call ModifySendStatus on a method "
|
||||
"which has a Cancel notification";
|
||||
}
|
||||
|
||||
std::multimap<std::string, std::string>* GetSendTrailingMetadata() override {
|
||||
CHECK(false) << "It is illegal to call GetSendTrailingMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call GetSendTrailingMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* GetRecvMessage() override {
|
||||
CHECK(false) << "It is illegal to call GetRecvMessage on a method which "
|
||||
"has a Cancel notification";
|
||||
ABSL_CHECK(false)
|
||||
<< "It is illegal to call GetRecvMessage on a method which "
|
||||
"has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
|
||||
override {
|
||||
CHECK(false) << "It is illegal to call GetRecvInitialMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call GetRecvInitialMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Status* GetRecvStatus() override {
|
||||
CHECK(false) << "It is illegal to call GetRecvStatus on a method which "
|
||||
"has a Cancel notification";
|
||||
ABSL_CHECK(false)
|
||||
<< "It is illegal to call GetRecvStatus on a method which "
|
||||
"has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
|
||||
override {
|
||||
CHECK(false) << "It is illegal to call GetRecvTrailingMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call GetRecvTrailingMetadata on a "
|
||||
"method which has a Cancel notification";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
|
||||
CHECK(false) << "It is illegal to call GetInterceptedChannel on a "
|
||||
"method which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call GetInterceptedChannel on a "
|
||||
"method which has a Cancel notification";
|
||||
return std::unique_ptr<ChannelInterface>(nullptr);
|
||||
}
|
||||
|
||||
void FailHijackedRecvMessage() override {
|
||||
CHECK(false) << "It is illegal to call FailHijackedRecvMessage on a "
|
||||
"method which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call FailHijackedRecvMessage on a "
|
||||
"method which has a Cancel notification";
|
||||
}
|
||||
|
||||
void FailHijackedSendMessage() override {
|
||||
CHECK(false) << "It is illegal to call FailHijackedSendMessage on a "
|
||||
"method which has a Cancel notification";
|
||||
ABSL_CHECK(false) << "It is illegal to call FailHijackedSendMessage on a "
|
||||
"method which has a Cancel notification";
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
#ifndef GRPCPP_IMPL_METADATA_MAP_H
|
||||
#define GRPCPP_IMPL_METADATA_MAP_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/support/slice.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
namespace internal {
|
||||
|
|
|
@ -19,15 +19,11 @@
|
|||
#ifndef GRPCPP_IMPL_PROTO_UTILS_H
|
||||
#define GRPCPP_IMPL_PROTO_UTILS_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/byte_buffer_reader.h>
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/codegen/config_protobuf.h>
|
||||
#include <grpcpp/impl/generic_serialize.h>
|
||||
#include <grpcpp/impl/serialization_traits.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/proto_buffer_reader.h>
|
||||
|
@ -35,65 +31,13 @@
|
|||
#include <grpcpp/support/slice.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
/// This header provides serialization and deserialization between gRPC
|
||||
/// messages serialized using protobuf and the C++ objects they represent.
|
||||
|
||||
namespace grpc {
|
||||
|
||||
// ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream.
|
||||
template <class ProtoBufferWriter, class T>
|
||||
Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb,
|
||||
bool* own_buffer) {
|
||||
static_assert(std::is_base_of<protobuf::io::ZeroCopyOutputStream,
|
||||
ProtoBufferWriter>::value,
|
||||
"ProtoBufferWriter must be a subclass of "
|
||||
"::protobuf::io::ZeroCopyOutputStream");
|
||||
*own_buffer = true;
|
||||
int byte_size = static_cast<int>(msg.ByteSizeLong());
|
||||
if (static_cast<size_t>(byte_size) <= GRPC_SLICE_INLINED_SIZE) {
|
||||
Slice slice(byte_size);
|
||||
// We serialize directly into the allocated slices memory
|
||||
CHECK(slice.end() == msg.SerializeWithCachedSizesToArray(
|
||||
const_cast<uint8_t*>(slice.begin())));
|
||||
ByteBuffer tmp(&slice, 1);
|
||||
bb->Swap(&tmp);
|
||||
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
ProtoBufferWriter writer(bb, kProtoBufferWriterMaxBufferLength, byte_size);
|
||||
return msg.SerializeToZeroCopyStream(&writer)
|
||||
? grpc::Status::OK
|
||||
: Status(StatusCode::INTERNAL, "Failed to serialize message");
|
||||
}
|
||||
|
||||
// BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream.
|
||||
template <class ProtoBufferReader, class T>
|
||||
Status GenericDeserialize(ByteBuffer* buffer,
|
||||
grpc::protobuf::MessageLite* msg) {
|
||||
static_assert(std::is_base_of<protobuf::io::ZeroCopyInputStream,
|
||||
ProtoBufferReader>::value,
|
||||
"ProtoBufferReader must be a subclass of "
|
||||
"::protobuf::io::ZeroCopyInputStream");
|
||||
if (buffer == nullptr) {
|
||||
return Status(StatusCode::INTERNAL, "No payload");
|
||||
}
|
||||
Status result = grpc::Status::OK;
|
||||
{
|
||||
ProtoBufferReader reader(buffer);
|
||||
if (!reader.status().ok()) {
|
||||
return reader.status();
|
||||
}
|
||||
if (!msg->ParseFromZeroCopyStream(&reader)) {
|
||||
result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
|
||||
}
|
||||
}
|
||||
buffer->Clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
// this is needed so the following class does not conflict with protobuf
|
||||
// serializers that utilize internal-only tools.
|
||||
#ifdef GRPC_OPEN_SOURCE_PROTO
|
||||
// This class provides a protobuf serializer. It translates between protobuf
|
||||
// objects and grpc_byte_buffers. More information about SerializationTraits can
|
||||
// be found in include/grpcpp/impl/codegen/serialization_traits.h.
|
||||
|
@ -112,7 +56,6 @@ class SerializationTraits<
|
|||
return GenericDeserialize<ProtoBufferReader, T>(buffer, msg);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
#ifndef GRPCPP_IMPL_RPC_METHOD_H
|
||||
#define GRPCPP_IMPL_RPC_METHOD_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/impl/codegen/channel_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
namespace internal {
|
||||
/// Descriptor of an RPC method
|
||||
|
|
|
@ -19,19 +19,19 @@
|
|||
#ifndef GRPCPP_IMPL_RPC_SERVICE_METHOD_H
|
||||
#define GRPCPP_IMPL_RPC_SERVICE_METHOD_H
|
||||
|
||||
#include <grpcpp/impl/rpc_method.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <climits>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/rpc_method.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
#include "absl/log/absl_check.h"
|
||||
#include "absl/log/absl_log.h"
|
||||
|
||||
namespace grpc {
|
||||
class ServerContextBase;
|
||||
|
@ -77,7 +77,7 @@ class MethodHandler {
|
|||
// retained by the handler. Returns nullptr if deserialization failed.
|
||||
virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req,
|
||||
Status* /*status*/, void** /*handler_data*/) {
|
||||
CHECK_EQ(req, nullptr);
|
||||
ABSL_CHECK_EQ(req, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
@ -116,12 +116,12 @@ class RpcServiceMethod : public RpcMethod {
|
|||
// this is not an error condition, as it allows users to declare a server
|
||||
// like WithRawMethod_foo<AsyncService>. However since it
|
||||
// overwrites behavior, it should be logged.
|
||||
gpr_log(
|
||||
GPR_INFO,
|
||||
"You are marking method %s as '%s', even though it was "
|
||||
"previously marked '%s'. This behavior will overwrite the original "
|
||||
"behavior. If you expected this then ignore this message.",
|
||||
name(), TypeToString(api_type_), TypeToString(type));
|
||||
ABSL_LOG(INFO)
|
||||
<< "You are marking method " << name() << " as '"
|
||||
<< TypeToString(api_type_)
|
||||
<< "', even though it was previously marked '" << TypeToString(type)
|
||||
<< "'. This behavior will overwrite the original behavior. If "
|
||||
"you expected this then ignore this message.";
|
||||
}
|
||||
api_type_ = type;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef GRPCPP_IMPL_SERVER_BUILDER_OPTION_H
|
||||
#define GRPCPP_IMPL_SERVER_BUILDER_OPTION_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/impl/server_builder_plugin.h>
|
||||
#include <grpcpp/support/channel_arguments.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
/// Interface to pass an option to a \a ServerBuilder.
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H
|
||||
#define GRPCPP_IMPL_SERVER_BUILDER_PLUGIN_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/support/channel_arguments.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class ServerBuilder;
|
||||
|
|
|
@ -18,17 +18,16 @@
|
|||
#ifndef GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H
|
||||
#define GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/impl/call.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/rpc_service_method.h>
|
||||
#include <grpcpp/server_context.h>
|
||||
#include <grpcpp/support/message_allocator.h>
|
||||
#include <grpcpp/support/server_callback.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
namespace grpc {
|
||||
namespace internal {
|
||||
|
||||
|
@ -117,8 +116,8 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
|
|||
// A callback that only contains a call to MaybeDone can be run as an
|
||||
// inline callback regardless of whether or not OnDone is inlineable
|
||||
// because if the actual OnDone callback needs to be scheduled, MaybeDone
|
||||
// is responsible for dispatching to an executor thread if needed. Thus,
|
||||
// when setting up the finish_tag_, we can set its own callback to
|
||||
// is responsible for dispatching to an EventEngine thread if needed.
|
||||
// Thus, when setting up the finish_tag_, we can set its own callback to
|
||||
// inlineable.
|
||||
finish_tag_.Set(
|
||||
call_.call(),
|
||||
|
@ -149,13 +148,13 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
|
|||
}
|
||||
|
||||
void SendInitialMetadata() override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
this->Ref();
|
||||
// The callback for this function should not be marked inline because it
|
||||
// is directly invoking a user-controlled reaction
|
||||
// (OnSendInitialMetadataDone). Thus it must be dispatched to an executor
|
||||
// thread. However, any OnDone needed after that can be inlined because it
|
||||
// is already running on an executor thread.
|
||||
// (OnSendInitialMetadataDone). Thus it must be dispatched to an
|
||||
// EventEngine thread. However, any OnDone needed after that can be
|
||||
// inlined because it is already running on an EventEngine thread.
|
||||
meta_tag_.Set(
|
||||
call_.call(),
|
||||
[this](bool ok) {
|
||||
|
@ -337,11 +336,11 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
|
|||
}
|
||||
|
||||
void SendInitialMetadata() override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
this->Ref();
|
||||
// The callback for this function should not be inlined because it invokes
|
||||
// a user-controlled reaction, but any resulting OnDone can be inlined in
|
||||
// the executor to which this callback is dispatched.
|
||||
// the EventEngine thread to which this callback is dispatched.
|
||||
meta_tag_.Set(
|
||||
call_.call(),
|
||||
[this](bool ok) {
|
||||
|
@ -381,7 +380,7 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
|
|||
reactor_.store(reactor, std::memory_order_relaxed);
|
||||
// The callback for this function should not be inlined because it invokes
|
||||
// a user-controlled reaction, but any resulting OnDone can be inlined in
|
||||
// the executor to which this callback is dispatched.
|
||||
// the EventEngine thread to which this callback is dispatched.
|
||||
read_tag_.Set(
|
||||
call_.call(),
|
||||
[this, reactor](bool ok) {
|
||||
|
@ -541,11 +540,11 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
|
|||
}
|
||||
|
||||
void SendInitialMetadata() override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
this->Ref();
|
||||
// The callback for this function should not be inlined because it invokes
|
||||
// a user-controlled reaction, but any resulting OnDone can be inlined in
|
||||
// the executor to which this callback is dispatched.
|
||||
// the EventEngine thread to which this callback is dispatched.
|
||||
meta_tag_.Set(
|
||||
call_.call(),
|
||||
[this](bool ok) {
|
||||
|
@ -579,7 +578,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
|
|||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// TODO(vjpai): don't assert
|
||||
CHECK(write_ops_.SendMessagePtr(resp, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessagePtr(resp, options).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
|
@ -587,7 +586,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
|
|||
grpc::Status s) override {
|
||||
// This combines the write into the finish callback
|
||||
// TODO(vjpai): don't assert
|
||||
CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
|
||||
ABSL_CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
|
||||
Finish(std::move(s));
|
||||
}
|
||||
|
||||
|
@ -608,7 +607,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
|
|||
reactor_.store(reactor, std::memory_order_relaxed);
|
||||
// The callback for this function should not be inlined because it invokes
|
||||
// a user-controlled reaction, but any resulting OnDone can be inlined in
|
||||
// the executor to which this callback is dispatched.
|
||||
// the EventEngine thread to which this callback is dispatched.
|
||||
write_tag_.Set(
|
||||
call_.call(),
|
||||
[this, reactor](bool ok) {
|
||||
|
@ -753,11 +752,11 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
|
|||
}
|
||||
|
||||
void SendInitialMetadata() override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
this->Ref();
|
||||
// The callback for this function should not be inlined because it invokes
|
||||
// a user-controlled reaction, but any resulting OnDone can be inlined in
|
||||
// the executor to which this callback is dispatched.
|
||||
// the EventEngine thread to which this callback is dispatched.
|
||||
meta_tag_.Set(
|
||||
call_.call(),
|
||||
[this](bool ok) {
|
||||
|
@ -791,14 +790,14 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
|
|||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// TODO(vjpai): don't assert
|
||||
CHECK(write_ops_.SendMessagePtr(resp, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessagePtr(resp, options).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void WriteAndFinish(const ResponseType* resp, grpc::WriteOptions options,
|
||||
grpc::Status s) override {
|
||||
// TODO(vjpai): don't assert
|
||||
CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
|
||||
ABSL_CHECK(finish_ops_.SendMessagePtr(resp, options).ok());
|
||||
Finish(std::move(s));
|
||||
}
|
||||
|
||||
|
@ -822,7 +821,7 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
|
|||
reactor_.store(reactor, std::memory_order_relaxed);
|
||||
// The callbacks for these functions should not be inlined because they
|
||||
// invoke user-controlled reactions, but any resulting OnDones can be
|
||||
// inlined in the executor to which a callback is dispatched.
|
||||
// inlined in the EventEngine thread to which a callback is dispatched.
|
||||
write_tag_.Set(
|
||||
call_.call(),
|
||||
[this, reactor](bool ok) {
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef GRPCPP_IMPL_SERVER_INITIALIZER_H
|
||||
#define GRPCPP_IMPL_SERVER_INITIALIZER_H
|
||||
|
||||
#include <grpcpp/server.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <grpcpp/server.h>
|
||||
|
||||
namespace grpc {
|
||||
class Server;
|
||||
class Service;
|
||||
|
|
|
@ -19,15 +19,14 @@
|
|||
#ifndef GRPCPP_IMPL_SERVICE_TYPE_H
|
||||
#define GRPCPP_IMPL_SERVICE_TYPE_H
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/rpc_service_method.h>
|
||||
#include <grpcpp/impl/serialization_traits.h>
|
||||
#include <grpcpp/server_interface.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class CompletionQueue;
|
||||
|
@ -152,7 +151,7 @@ class Service {
|
|||
// This does not have to be a hard error, however no one has approached us
|
||||
// with a use case yet. Please file an issue if you believe you have one.
|
||||
size_t idx = static_cast<size_t>(index);
|
||||
CHECK_NE(methods_[idx].get(), nullptr)
|
||||
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
|
||||
<< "Cannot mark the method as 'async' because it has already been "
|
||||
"marked as 'generic'.";
|
||||
methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::ASYNC);
|
||||
|
@ -162,7 +161,7 @@ class Service {
|
|||
// This does not have to be a hard error, however no one has approached us
|
||||
// with a use case yet. Please file an issue if you believe you have one.
|
||||
size_t idx = static_cast<size_t>(index);
|
||||
CHECK_NE(methods_[idx].get(), nullptr)
|
||||
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
|
||||
<< "Cannot mark the method as 'raw' because it has already "
|
||||
"been marked as 'generic'.";
|
||||
methods_[idx]->SetServerApiType(internal::RpcServiceMethod::ApiType::RAW);
|
||||
|
@ -172,7 +171,7 @@ class Service {
|
|||
// This does not have to be a hard error, however no one has approached us
|
||||
// with a use case yet. Please file an issue if you believe you have one.
|
||||
size_t idx = static_cast<size_t>(index);
|
||||
CHECK_NE(methods_[idx]->handler(), nullptr)
|
||||
ABSL_CHECK_NE(methods_[idx]->handler(), nullptr)
|
||||
<< "Cannot mark the method as 'generic' because it has already been "
|
||||
"marked as 'async' or 'raw'.";
|
||||
methods_[idx].reset();
|
||||
|
@ -182,7 +181,7 @@ class Service {
|
|||
// This does not have to be a hard error, however no one has approached us
|
||||
// with a use case yet. Please file an issue if you believe you have one.
|
||||
size_t idx = static_cast<size_t>(index);
|
||||
CHECK(methods_[idx] && methods_[idx]->handler())
|
||||
ABSL_CHECK(methods_[idx] && methods_[idx]->handler())
|
||||
<< "Cannot mark an async or generic method Streamed";
|
||||
methods_[idx]->SetHandler(streamed_method);
|
||||
|
||||
|
@ -197,7 +196,7 @@ class Service {
|
|||
// This does not have to be a hard error, however no one has approached us
|
||||
// with a use case yet. Please file an issue if you believe you have one.
|
||||
size_t idx = static_cast<size_t>(index);
|
||||
CHECK_NE(methods_[idx].get(), nullptr)
|
||||
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
|
||||
<< "Cannot mark the method as 'callback' because it has already been "
|
||||
"marked as 'generic'.";
|
||||
methods_[idx]->SetHandler(handler);
|
||||
|
@ -209,7 +208,7 @@ class Service {
|
|||
// This does not have to be a hard error, however no one has approached us
|
||||
// with a use case yet. Please file an issue if you believe you have one.
|
||||
size_t idx = static_cast<size_t>(index);
|
||||
CHECK_NE(methods_[idx].get(), nullptr)
|
||||
ABSL_CHECK_NE(methods_[idx].get(), nullptr)
|
||||
<< "Cannot mark the method as 'raw callback' because it has already "
|
||||
"been marked as 'generic'.";
|
||||
methods_[idx]->SetHandler(handler);
|
||||
|
|
|
@ -25,21 +25,20 @@
|
|||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/sync.h>
|
||||
#include <grpc/support/time.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
|
||||
// The core library is not accessible in C++ codegen headers, and vice versa.
|
||||
// Thus, we need to have duplicate headers with similar functionality.
|
||||
// Make sure any change to this file is also reflected in
|
||||
// src/core/lib/gprpp/sync.h too.
|
||||
// src/core/util/sync.h too.
|
||||
//
|
||||
// Whenever possible, prefer "src/core/lib/gprpp/sync.h" over this file,
|
||||
// Whenever possible, prefer "src/core/util/sync.h" over this file,
|
||||
// since in core we do not rely on g_core_codegen_interface and hence do not
|
||||
// pay the costs of virtual function calls.
|
||||
|
||||
|
@ -106,7 +105,7 @@ class ABSL_SCOPED_LOCKABLE ReleasableMutexLock {
|
|||
ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete;
|
||||
|
||||
void Release() ABSL_UNLOCK_FUNCTION() {
|
||||
DCHECK(!released_);
|
||||
ABSL_DCHECK(!released_);
|
||||
released_ = true;
|
||||
mu_->Unlock();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2022 gRPC authors.
|
||||
// Copyright 2024 The gRPC Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -11,14 +11,17 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef GRPCPP_PASSIVE_LISTENER_H
|
||||
#define GRPCPP_PASSIVE_LISTENER_H
|
||||
|
||||
#ifndef GRPC_SRC_CORE_LIB_PROMISE_TRACE_H
|
||||
#define GRPC_SRC_CORE_LIB_PROMISE_TRACE_H
|
||||
#include <grpc/passive_listener.h>
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
||||
#include "src/core/lib/debug/trace.h"
|
||||
using grpc_core::experimental::PassiveListener;
|
||||
|
||||
extern grpc_core::DebugOnlyTraceFlag grpc_trace_promise_primitives;
|
||||
} // namespace experimental
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPC_SRC_CORE_LIB_PROMISE_TRACE_H
|
||||
#endif // GRPCPP_PASSIVE_LISTENER_H
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2025 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Protect Code from unwanted/inconvienet macros
|
||||
* you must follow this pattern when #including port_def.inc in a header file:
|
||||
*
|
||||
* #include "other_header.h"
|
||||
* #include "message.h"
|
||||
* etc.
|
||||
*
|
||||
* #include "port_def.inc" // MUST be last header included
|
||||
*
|
||||
* Definitions for this header.
|
||||
*
|
||||
* #include "port_undef.inc" //At end of file
|
||||
*
|
||||
* This is a textual header with no include guard, because we want to
|
||||
* detect/prohibit anytime it is #included twice without a corresponding
|
||||
* #undef.
|
||||
*/
|
||||
|
||||
#ifdef GRPC_PORT_
|
||||
#error "port_def.inc included multiple times"
|
||||
#endif
|
||||
#define GRPC_PORT_
|
||||
|
||||
|
||||
// Windows declares several inconvenient macro names. We #undef them and then
|
||||
// restore them in port_undef.inc.
|
||||
#ifdef _WIN32
|
||||
#pragma push_macro("CompareString")
|
||||
#undef CompareString
|
||||
#pragma push_macro("CREATE_NEW")
|
||||
#undef CREATE_NEW
|
||||
#pragma push_macro("DELETE")
|
||||
#undef DELETE
|
||||
#pragma push_macro("DOUBLE_CLICK")
|
||||
#undef DOUBLE_CLICK
|
||||
#pragma push_macro("ERROR")
|
||||
#undef ERROR
|
||||
#pragma push_macro("ERROR_BUSY")
|
||||
#undef ERROR_BUSY
|
||||
#pragma push_macro("ERROR_INSTALL_FAILED")
|
||||
#undef ERROR_INSTALL_FAILED
|
||||
#pragma push_macro("ERROR_NOT_FOUND")
|
||||
#undef ERROR_NOT_FOUND
|
||||
#pragma push_macro("ERROR_RETRY")
|
||||
#undef ERROR_RETRY
|
||||
#pragma push_macro("ERROR_TIMEOUT")
|
||||
#undef ERROR_TIMEOUT
|
||||
#pragma push_macro("GetClassName")
|
||||
#undef GetClassName
|
||||
#pragma push_macro("GetCurrentTime")
|
||||
#undef GetCurrentTime
|
||||
#pragma push_macro("GetMessage")
|
||||
#undef GetMessage
|
||||
#pragma push_macro("GetObject")
|
||||
#undef GetObject
|
||||
#pragma push_macro("IGNORE")
|
||||
#undef IGNORE
|
||||
#pragma push_macro("IN")
|
||||
#undef IN
|
||||
#pragma push_macro("INPUT_KEYBOARD")
|
||||
#undef INPUT_KEYBOARD
|
||||
#pragma push_macro("NO_ERROR")
|
||||
#undef NO_ERROR
|
||||
#pragma push_macro("OUT")
|
||||
#undef OUT
|
||||
#pragma push_macro("OPTIONAL")
|
||||
#undef OPTIONAL
|
||||
#pragma push_macro("min")
|
||||
#undef min
|
||||
#pragma push_macro("max")
|
||||
#undef max
|
||||
#pragma push_macro("NEAR")
|
||||
#undef NEAR
|
||||
#pragma push_macro("NO_DATA")
|
||||
#undef NO_DATA
|
||||
#pragma push_macro("REASON_UNKNOWN")
|
||||
#undef REASON_UNKNOWN
|
||||
#pragma push_macro("SERVICE_DISABLED")
|
||||
#undef SERVICE_DISABLED
|
||||
#pragma push_macro("SERVICE_STOP")
|
||||
#undef SERVICE_STOP
|
||||
#pragma push_macro("SEVERITY_ERROR")
|
||||
#undef SEVERITY_ERROR
|
||||
#pragma push_macro("STATUS_PENDING")
|
||||
#undef STATUS_PENDING
|
||||
#pragma push_macro("STRICT")
|
||||
#undef STRICT
|
||||
#pragma push_macro("timezone")
|
||||
#undef timezone
|
||||
#pragma push_macro("TRUE")
|
||||
#undef TRUE
|
||||
#pragma push_macro("FALSE")
|
||||
#undef FALSE
|
||||
#pragma push_macro("UNICODE")
|
||||
#undef UNICODE
|
||||
#endif // _WIN32
|
||||
|
||||
#ifdef __APPLE__
|
||||
// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs.
|
||||
#pragma push_macro("TRUE")
|
||||
#undef TRUE
|
||||
#pragma push_macro("FALSE")
|
||||
#undef FALSE
|
||||
// Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs.
|
||||
#pragma push_macro("UID_MAX")
|
||||
#undef UID_MAX
|
||||
#pragma push_macro("GID_MAX")
|
||||
#undef GID_MAX
|
||||
// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.
|
||||
#pragma push_macro("TYPE_BOOL")
|
||||
#undef TYPE_BOOL
|
||||
#endif // __APPLE__
|
||||
|
||||
#if defined(ANDROID) || defined(__ANDROID__)
|
||||
// Inconvenient macro names from usr/include/limits.h in some Android NDKs.
|
||||
#pragma push_macro("UID_MAX")
|
||||
#undef UID_MAX
|
||||
#pragma push_macro("GID_MAX")
|
||||
#undef GID_MAX
|
||||
#endif // defined(ANDROID) || defined(__ANDROID__)
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2025 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* #undefs all macros defined in port_def.inc. See comments in port_def.inc
|
||||
* for more info.
|
||||
*/
|
||||
|
||||
#ifndef GRPC_PORT_
|
||||
#error "port_undef.inc must be included after port_def.inc"
|
||||
#endif
|
||||
#undef GRPC_PORT_
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma pop_macro("CompareString")
|
||||
#pragma pop_macro("CREATE_NEW")
|
||||
#pragma pop_macro("DELETE")
|
||||
#pragma pop_macro("DOUBLE_CLICK")
|
||||
#pragma pop_macro("ERROR")
|
||||
#pragma pop_macro("ERROR_BUSY")
|
||||
#pragma pop_macro("ERROR_INSTALL_FAILED")
|
||||
#pragma pop_macro("ERROR_NOT_FOUND")
|
||||
#pragma pop_macro("ERROR_RETRY")
|
||||
#pragma pop_macro("ERROR_TIMEOUT")
|
||||
#pragma pop_macro("GetClassName")
|
||||
#pragma pop_macro("GetCurrentTime")
|
||||
#pragma pop_macro("GetMessage")
|
||||
#pragma pop_macro("GetObject")
|
||||
#pragma pop_macro("IGNORE")
|
||||
#pragma pop_macro("IN")
|
||||
#pragma pop_macro("INPUT_KEYBOARD")
|
||||
#pragma pop_macro("NO_ERROR")
|
||||
#pragma pop_macro("OUT")
|
||||
#pragma pop_macro("OPTIONAL")
|
||||
#pragma pop_macro("min")
|
||||
#pragma pop_macro("max")
|
||||
#pragma pop_macro("NEAR")
|
||||
#pragma pop_macro("NO_DATA")
|
||||
#pragma pop_macro("REASON_UNKNOWN")
|
||||
#pragma pop_macro("SERVICE_DISABLED")
|
||||
#pragma pop_macro("SERVICE_STOP")
|
||||
#pragma pop_macro("SEVERITY_ERROR")
|
||||
#pragma pop_macro("STRICT")
|
||||
#pragma pop_macro("STATUS_PENDING")
|
||||
#pragma pop_macro("timezone")
|
||||
#pragma pop_macro("TRUE")
|
||||
#pragma pop_macro("FALSE")
|
||||
#pragma pop_macro("UNICODE")
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#pragma pop_macro("TRUE")
|
||||
#pragma pop_macro("FALSE")
|
||||
#pragma pop_macro("UID_MAX")
|
||||
#pragma pop_macro("GID_MAX")
|
||||
#pragma pop_macro("TYPE_BOOL")
|
||||
#endif // __APPLE__
|
||||
|
||||
#if defined(ANDROID) || defined(__ANDROID__)
|
||||
#pragma pop_macro("UID_MAX")
|
||||
#pragma pop_macro("GID_MAX")
|
||||
#endif // defined(ANDROID) || defined(__ANDROID__)
|
||||
|
|
@ -19,15 +19,15 @@
|
|||
#ifndef GRPCPP_SECURITY_AUDIT_LOGGING_H
|
||||
#define GRPCPP_SECURITY_AUDIT_LOGGING_H
|
||||
|
||||
#include <grpc/grpc_audit_logging.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
|
||||
#include <grpc/grpc_audit_logging.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef GRPCPP_SECURITY_AUTH_CONTEXT_H
|
||||
#define GRPCPP_SECURITY_AUTH_CONTEXT_H
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
struct grpc_auth_context;
|
||||
struct grpc_auth_property;
|
||||
struct grpc_auth_property_iterator;
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H
|
||||
#define GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <grpcpp/security/auth_context.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
/// Interface allowing custom server-side authorization based on credentials
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
#ifndef GRPCPP_SECURITY_AUTHORIZATION_POLICY_PROVIDER_H
|
||||
#define GRPCPP_SECURITY_AUTHORIZATION_POLICY_PROVIDER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpc/grpc_security.h>
|
||||
#include <grpc/status.h>
|
||||
#include <grpcpp/impl/codegen/status.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright 2021 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef GRPCPP_SECURITY_BINDER_CREDENTIALS_H
|
||||
#define GRPCPP_SECURITY_BINDER_CREDENTIALS_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpcpp/security/binder_security_policy.h>
|
||||
#include <grpcpp/security/server_credentials.h>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class ChannelCredentials;
|
||||
|
||||
namespace experimental {
|
||||
|
||||
/// EXPERIMENTAL Builds Binder ServerCredentials.
|
||||
///
|
||||
/// This should be used along with `binder:` URI scheme. The path in the URI can
|
||||
/// later be used to access the server's endpoint binder.
|
||||
/// Note that calling \a ServerBuilder::AddListeningPort() with Binder
|
||||
/// ServerCredentials in a non-supported environment will make the subsequent
|
||||
/// call to \a ServerBuilder::BuildAndStart() return a null pointer.
|
||||
std::shared_ptr<grpc::ServerCredentials> BinderServerCredentials(
|
||||
std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
|
||||
security_policy);
|
||||
|
||||
} // namespace experimental
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_SECURITY_BINDER_CREDENTIALS_H
|
|
@ -1,82 +0,0 @@
|
|||
// Copyright 2021 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef GRPCPP_SECURITY_BINDER_SECURITY_POLICY_H
|
||||
#define GRPCPP_SECURITY_BINDER_SECURITY_POLICY_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#ifdef GPR_ANDROID
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
namespace binder {
|
||||
|
||||
// EXPERIMENTAL Determinines if a connection is allowed to be
|
||||
// established on Android. See https://source.android.com/security/app-sandbox
|
||||
// for more info about UID.
|
||||
class SecurityPolicy {
|
||||
public:
|
||||
virtual ~SecurityPolicy() = default;
|
||||
// Returns true if the UID is authorized to connect.
|
||||
// Must return the same value for the same inputs so callers can safely cache
|
||||
// the result.
|
||||
virtual bool IsAuthorized(int uid) = 0;
|
||||
};
|
||||
|
||||
// EXPERIMENTAL Allows all connection. Anything on the Android device will be
|
||||
// able to connect, use with caution!
|
||||
class UntrustedSecurityPolicy : public SecurityPolicy {
|
||||
public:
|
||||
UntrustedSecurityPolicy();
|
||||
~UntrustedSecurityPolicy() override;
|
||||
bool IsAuthorized(int uid) override;
|
||||
};
|
||||
|
||||
// EXPERIMENTAL Only allows the connections from processes with the same UID. In
|
||||
// most cases this means "from the same APK".
|
||||
class InternalOnlySecurityPolicy : public SecurityPolicy {
|
||||
public:
|
||||
InternalOnlySecurityPolicy();
|
||||
~InternalOnlySecurityPolicy() override;
|
||||
bool IsAuthorized(int uid) override;
|
||||
};
|
||||
|
||||
#ifdef GPR_ANDROID
|
||||
|
||||
// EXPERIMENTAL Only allows the connections from the APK that have the same
|
||||
// signature.
|
||||
class SameSignatureSecurityPolicy : public SecurityPolicy {
|
||||
public:
|
||||
// `context` is required for getting PackageManager Java class
|
||||
SameSignatureSecurityPolicy(JavaVM* jvm, jobject context);
|
||||
~SameSignatureSecurityPolicy() override;
|
||||
bool IsAuthorized(int uid) override;
|
||||
|
||||
private:
|
||||
JavaVM* jvm_;
|
||||
jobject context_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace binder
|
||||
} // namespace experimental
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_SECURITY_BINDER_SECURITY_POLICY_H
|
|
@ -19,10 +19,6 @@
|
|||
#ifndef GRPCPP_SECURITY_CREDENTIALS_H
|
||||
#define GRPCPP_SECURITY_CREDENTIALS_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/grpc_security_constants.h>
|
||||
#include <grpcpp/channel.h>
|
||||
#include <grpcpp/impl/grpc_library.h>
|
||||
|
@ -33,6 +29,10 @@
|
|||
#include <grpcpp/support/status.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct grpc_call;
|
||||
|
||||
namespace grpc {
|
||||
|
@ -247,7 +247,7 @@ class MetadataCredentialsPlugin {
|
|||
/// Type of credentials this plugin is implementing.
|
||||
virtual const char* GetType() const { return ""; }
|
||||
|
||||
/// Gets the auth metatada produced by this plugin.
|
||||
/// Gets the auth metadata produced by this plugin.
|
||||
/// The fully qualified method name is:
|
||||
/// service_url + "/" + method_name.
|
||||
/// The channel_auth_context contains (among other things), the identity of
|
||||
|
@ -295,7 +295,7 @@ grpc::Status StsCredentialsOptionsFromJson(const std::string& json_string,
|
|||
|
||||
/// Creates STS credentials options from the $STS_CREDENTIALS environment
|
||||
/// variable. This environment variable points to the path of a JSON file
|
||||
/// comforming to the schema described above.
|
||||
/// conforming to the schema described above.
|
||||
grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options);
|
||||
|
||||
std::shared_ptr<CallCredentials> StsCredentials(
|
||||
|
|
|
@ -19,15 +19,15 @@
|
|||
#ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_H
|
||||
#define GRPCPP_SECURITY_SERVER_CREDENTIALS_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/grpc_security_constants.h>
|
||||
#include <grpcpp/impl/grpc_library.h>
|
||||
#include <grpcpp/security/auth_metadata_processor.h>
|
||||
#include <grpcpp/security/tls_credentials_options.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct grpc_server;
|
||||
|
||||
namespace grpc {
|
||||
|
@ -84,6 +84,7 @@ class ServerCredentials : private grpc::internal::GrpcLibrary {
|
|||
// Needed for access to AddPortToServer.
|
||||
friend class Server;
|
||||
// Needed for access to c_creds_.
|
||||
friend class ServerBuilder;
|
||||
friend std::shared_ptr<ServerCredentials> grpc::XdsServerCredentials(
|
||||
const std::shared_ptr<ServerCredentials>& fallback_credentials);
|
||||
|
||||
|
@ -115,9 +116,6 @@ std::shared_ptr<ServerCredentials> AltsServerCredentials(
|
|||
const AltsServerCredentialsOptions& options);
|
||||
|
||||
/// Builds Local ServerCredentials.
|
||||
std::shared_ptr<ServerCredentials> AltsServerCredentials(
|
||||
const AltsServerCredentialsOptions& options);
|
||||
|
||||
std::shared_ptr<ServerCredentials> LocalServerCredentials(
|
||||
grpc_local_connect_type type);
|
||||
|
||||
|
|
|
@ -17,16 +17,19 @@
|
|||
#ifndef GRPCPP_SECURITY_TLS_CERTIFICATE_PROVIDER_H
|
||||
#define GRPCPP_SECURITY_TLS_CERTIFICATE_PROVIDER_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/credentials.h>
|
||||
#include <grpc/grpc_security.h>
|
||||
#include <grpc/grpc_security_constants.h>
|
||||
#include <grpc/status.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
||||
|
@ -68,6 +71,12 @@ class GRPCXX_DLL StaticDataCertificateProvider
|
|||
|
||||
grpc_tls_certificate_provider* c_provider() override { return c_provider_; }
|
||||
|
||||
// Returns an OK status if the following conditions hold:
|
||||
// - the root certificates consist of one or more valid PEM blocks, and
|
||||
// - every identity key-cert pair has a certificate chain that consists of
|
||||
// valid PEM blocks and has a private key is a valid PEM block.
|
||||
absl::Status ValidateCredentials() const;
|
||||
|
||||
private:
|
||||
grpc_tls_certificate_provider* c_provider_ = nullptr;
|
||||
};
|
||||
|
@ -118,6 +127,14 @@ class GRPCXX_DLL FileWatcherCertificateProvider final
|
|||
|
||||
grpc_tls_certificate_provider* c_provider() override { return c_provider_; }
|
||||
|
||||
// Returns an OK status if the following conditions hold:
|
||||
// - the currently-loaded root certificates, if any, consist of one or more
|
||||
// valid PEM blocks, and
|
||||
// - every currently-loaded identity key-cert pair, if any, has a certificate
|
||||
// chain that consists of valid PEM blocks and has a private key is a valid
|
||||
// PEM block.
|
||||
absl::Status ValidateCredentials() const;
|
||||
|
||||
private:
|
||||
grpc_tls_certificate_provider* c_provider_ = nullptr;
|
||||
};
|
||||
|
|
|
@ -17,21 +17,20 @@
|
|||
#ifndef GRPCPP_SECURITY_TLS_CERTIFICATE_VERIFIER_H
|
||||
#define GRPCPP_SECURITY_TLS_CERTIFICATE_VERIFIER_H
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/grpc_security_constants.h>
|
||||
#include <grpc/status.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/grpc_library.h>
|
||||
#include <grpcpp/impl/sync.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
#include <grpcpp/support/string_ref.h>
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// TODO(yihuazhang): remove the forward declaration here and include
|
||||
// <grpc/grpc_security.h> directly once the insecure builds are cleaned up.
|
||||
typedef struct grpc_tls_custom_verification_check_request
|
||||
|
|
|
@ -19,18 +19,17 @@
|
|||
#ifndef GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H
|
||||
#define GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/grpc_security.h>
|
||||
#include <grpc/grpc_security_constants.h>
|
||||
#include <grpc/status.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/security/tls_certificate_provider.h>
|
||||
#include <grpcpp/security/tls_certificate_verifier.h>
|
||||
#include <grpcpp/security/tls_crl_provider.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace grpc {
|
||||
namespace experimental {
|
||||
|
||||
|
@ -103,6 +102,8 @@ class TlsCredentialsOptions {
|
|||
// call is covered by the cert that the peer presented.
|
||||
// We will perform such checks by default. This should be disabled if
|
||||
// verifiers other than the host name verifier is used.
|
||||
// Deprecated: This function will be removed in the 1.66 release. This will be
|
||||
// replaced by and handled within the custom verifier settings.
|
||||
void set_check_call_host(bool check_call_host);
|
||||
|
||||
// Deprecated in favor of set_crl_provider. The
|
||||
|
@ -111,6 +112,8 @@ class TlsCredentialsOptions {
|
|||
// If set, gRPC will read all hashed x.509 CRL files in the directory and
|
||||
// enforce the CRL files on all TLS handshakes. Only supported for OpenSSL
|
||||
// version > 1.1.
|
||||
// Deprecated: This function will be removed in the 1.66 release. Use the
|
||||
// set_crl_provider function instead.
|
||||
void set_crl_directory(const std::string& path);
|
||||
|
||||
void set_crl_provider(std::shared_ptr<CrlProvider> crl_provider);
|
||||
|
@ -184,6 +187,7 @@ class TlsServerCredentialsOptions final : public TlsCredentialsOptions {
|
|||
// WARNING: This API is extremely dangerous and should not be used. If the
|
||||
// server's trust bundle is too large, then the TLS server will be unable to
|
||||
// form a ServerHello, and hence will be unusable.
|
||||
// Deprecated: This function will be removed in the 1.66 release.
|
||||
void set_send_client_ca_list(bool send_client_ca_list);
|
||||
|
||||
private:
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
#ifndef GRPCPP_SERVER_H
|
||||
#define GRPCPP_SERVER_H
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/compression.h>
|
||||
#include <grpc/support/atm.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
@ -39,6 +35,10 @@
|
|||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct grpc_server;
|
||||
|
||||
namespace grpc {
|
||||
|
|
|
@ -19,23 +19,27 @@
|
|||
#ifndef GRPCPP_SERVER_BUILDER_H
|
||||
#define GRPCPP_SERVER_BUILDER_H
|
||||
|
||||
#include <climits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/compression.h>
|
||||
#include <grpc/event_engine/event_engine.h>
|
||||
#include <grpc/passive_listener.h>
|
||||
#include <grpc/support/cpu.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpc/support/workaround_list.h>
|
||||
#include <grpcpp/impl/channel_argument_option.h>
|
||||
#include <grpcpp/impl/server_builder_option.h>
|
||||
#include <grpcpp/impl/server_builder_plugin.h>
|
||||
#include <grpcpp/passive_listener.h>
|
||||
#include <grpcpp/security/authorization_policy_provider.h>
|
||||
#include <grpcpp/security/server_credentials.h>
|
||||
#include <grpcpp/server.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/server_interceptor.h>
|
||||
|
||||
#include <climits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct grpc_resource_quota;
|
||||
|
||||
namespace grpc {
|
||||
|
@ -291,6 +295,18 @@ class ServerBuilder {
|
|||
void EnableCallMetricRecording(
|
||||
experimental::ServerMetricRecorder* server_metric_recorder = nullptr);
|
||||
|
||||
// Creates a passive listener for Server Endpoint injection.
|
||||
///
|
||||
/// \a PassiveListener lets applications provide pre-established connections
|
||||
/// to gRPC Servers. The server will behave as if it accepted the connection
|
||||
/// itself on its own listening addresses.
|
||||
///
|
||||
/// This can be called multiple times to create passive listeners with
|
||||
/// different server credentials.
|
||||
ServerBuilder& AddPassiveListener(
|
||||
std::shared_ptr<grpc::ServerCredentials> creds,
|
||||
std::unique_ptr<grpc::experimental::PassiveListener>& passive_listener);
|
||||
|
||||
private:
|
||||
ServerBuilder* builder_;
|
||||
};
|
||||
|
@ -364,6 +380,17 @@ class ServerBuilder {
|
|||
private:
|
||||
friend class grpc::testing::ServerBuilderPluginTest;
|
||||
|
||||
struct UnstartedPassiveListener {
|
||||
std::weak_ptr<grpc_core::experimental::PassiveListenerImpl>
|
||||
passive_listener;
|
||||
std::shared_ptr<grpc::ServerCredentials> credentials;
|
||||
UnstartedPassiveListener(
|
||||
std::weak_ptr<grpc_core::experimental::PassiveListenerImpl> listener,
|
||||
std::shared_ptr<grpc::ServerCredentials> creds)
|
||||
: passive_listener(std::move(listener)),
|
||||
credentials(std::move(creds)) {}
|
||||
};
|
||||
|
||||
struct SyncServerSettings {
|
||||
SyncServerSettings()
|
||||
: num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {}
|
||||
|
@ -388,6 +415,7 @@ class ServerBuilder {
|
|||
std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_;
|
||||
std::vector<std::unique_ptr<NamedService>> services_;
|
||||
std::vector<Port> ports_;
|
||||
std::vector<UnstartedPassiveListener> unstarted_passive_listeners_;
|
||||
|
||||
SyncServerSettings sync_server_settings_;
|
||||
|
||||
|
|
|
@ -19,13 +19,6 @@
|
|||
#ifndef GRPCPP_SERVER_CONTEXT_H
|
||||
#define GRPCPP_SERVER_CONTEXT_H
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/impl/call.h>
|
||||
#include <grpc/impl/compression_types.h>
|
||||
|
@ -47,6 +40,13 @@
|
|||
#include <grpcpp/support/string_ref.h>
|
||||
#include <grpcpp/support/time.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
struct grpc_metadata;
|
||||
struct grpc_call;
|
||||
struct census_context;
|
||||
|
@ -501,9 +501,9 @@ class ServerContextBase {
|
|||
void OnCancel() override {}
|
||||
void OnDone() override {}
|
||||
// Override InternalInlineable for this class since its reactions are
|
||||
// trivial and thus do not need to be run from the executor (triggering a
|
||||
// thread hop). This should only be used by internal reactors (thus the
|
||||
// name) and not by user application code.
|
||||
// trivial and thus do not need to be run from the EventEngine (potentially
|
||||
// triggering a thread hop). This should only be used by internal reactors
|
||||
// (thus the name) and not by user application code.
|
||||
bool InternalInlineable() override { return true; }
|
||||
};
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@
|
|||
#ifndef GRPCPP_SERVER_INTERFACE_H
|
||||
#define GRPCPP_SERVER_INTERFACE_H
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpc/support/time.h>
|
||||
#include <grpcpp/impl/call.h>
|
||||
|
@ -34,6 +31,8 @@
|
|||
#include <grpcpp/server_context.h>
|
||||
#include <grpcpp/support/byte_buffer.h>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class AsyncGenericService;
|
||||
|
@ -320,7 +319,7 @@ class ServerInterface : public internal::CallHook {
|
|||
grpc::CompletionQueue* call_cq,
|
||||
grpc::ServerCompletionQueue* notification_cq, void* tag,
|
||||
Message* message) {
|
||||
CHECK(method);
|
||||
ABSL_CHECK(method);
|
||||
new PayloadAsyncRequest<Message>(method, this, context, stream, call_cq,
|
||||
notification_cq, tag, message);
|
||||
}
|
||||
|
@ -331,7 +330,7 @@ class ServerInterface : public internal::CallHook {
|
|||
grpc::CompletionQueue* call_cq,
|
||||
grpc::ServerCompletionQueue* notification_cq,
|
||||
void* tag) {
|
||||
CHECK(method);
|
||||
ABSL_CHECK(method);
|
||||
new NoPayloadAsyncRequest(method, this, context, stream, call_cq,
|
||||
notification_cq, tag);
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#ifndef GRPCPP_SERVER_POSIX_H
|
||||
#define GRPCPP_SERVER_POSIX_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include <grpcpp/server.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD
|
||||
|
|
|
@ -19,16 +19,15 @@
|
|||
#ifndef GRPCPP_SUPPORT_ASYNC_STREAM_H
|
||||
#define GRPCPP_SUPPORT_ASYNC_STREAM_H
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/call.h>
|
||||
#include <grpcpp/impl/channel_interface.h>
|
||||
#include <grpcpp/impl/service_type.h>
|
||||
#include <grpcpp/server_context.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
namespace grpc {
|
||||
|
||||
namespace internal {
|
||||
|
@ -39,7 +38,11 @@ class ClientAsyncStreamingInterface {
|
|||
|
||||
/// Start the call that was set up by the constructor, but only if the
|
||||
/// constructor was invoked through the "Prepare" API which doesn't actually
|
||||
/// start the call
|
||||
/// start the call.
|
||||
///
|
||||
/// It is illegal to start a write-type operation (eg. Write(), WriteLast(),
|
||||
/// WritesDone()) while the `StartCall()` operation has not finished
|
||||
/// (determined by the returning of \a tag).
|
||||
virtual void StartCall(void* tag) = 0;
|
||||
|
||||
/// Request notification of the reading of the initial metadata. Completion
|
||||
|
@ -202,7 +205,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
|
|||
public:
|
||||
// always allocated against a call arena, no memory free required
|
||||
static void operator delete(void* /*ptr*/, std::size_t size) {
|
||||
CHECK_EQ(size, sizeof(ClientAsyncReader));
|
||||
ABSL_CHECK_EQ(size, sizeof(ClientAsyncReader));
|
||||
}
|
||||
|
||||
// This operator should never be called as the memory should be freed as part
|
||||
|
@ -210,10 +213,10 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
|
|||
// delete to the operator new so that some compilers will not complain (see
|
||||
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
|
||||
// there are no tests catching the compiler warning.
|
||||
static void operator delete(void*, void*) { CHECK(false); }
|
||||
static void operator delete(void*, void*) { ABSL_CHECK(false); }
|
||||
|
||||
void StartCall(void* tag) override {
|
||||
CHECK(!started_);
|
||||
ABSL_CHECK(!started_);
|
||||
started_ = true;
|
||||
StartCallInternal(tag);
|
||||
}
|
||||
|
@ -227,8 +230,8 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
|
|||
/// calling code can access the received metadata through the
|
||||
/// \a ClientContext.
|
||||
void ReadInitialMetadata(void* tag) override {
|
||||
CHECK(started_);
|
||||
CHECK(!context_->initial_metadata_received_);
|
||||
ABSL_CHECK(started_);
|
||||
ABSL_CHECK(!context_->initial_metadata_received_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -236,7 +239,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
|
|||
}
|
||||
|
||||
void Read(R* msg, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
read_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
read_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -251,7 +254,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
|
|||
/// - the \a ClientContext associated with this call is updated with
|
||||
/// possible initial and trailing metadata received from the server.
|
||||
void Finish(grpc::Status* status, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
finish_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -267,12 +270,12 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
|
|||
const W& request, bool start, void* tag)
|
||||
: context_(context), call_(call), started_(start) {
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(init_ops_.SendMessage(request).ok());
|
||||
ABSL_CHECK(init_ops_.SendMessage(request).ok());
|
||||
init_ops_.ClientSendClose();
|
||||
if (start) {
|
||||
StartCallInternal(tag);
|
||||
} else {
|
||||
CHECK(tag == nullptr);
|
||||
ABSL_CHECK(tag == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,7 +353,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
|
|||
public:
|
||||
// always allocated against a call arena, no memory free required
|
||||
static void operator delete(void* /*ptr*/, std::size_t size) {
|
||||
CHECK_EQ(size, sizeof(ClientAsyncWriter));
|
||||
ABSL_CHECK_EQ(size, sizeof(ClientAsyncWriter));
|
||||
}
|
||||
|
||||
// This operator should never be called as the memory should be freed as part
|
||||
|
@ -358,10 +361,10 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
|
|||
// delete to the operator new so that some compilers will not complain (see
|
||||
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
|
||||
// there are no tests catching the compiler warning.
|
||||
static void operator delete(void*, void*) { CHECK(false); }
|
||||
static void operator delete(void*, void*) { ABSL_CHECK(false); }
|
||||
|
||||
void StartCall(void* tag) override {
|
||||
CHECK(!started_);
|
||||
ABSL_CHECK(!started_);
|
||||
started_ = true;
|
||||
StartCallInternal(tag);
|
||||
}
|
||||
|
@ -374,8 +377,8 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
|
|||
/// associated with this call is updated, and the calling code can access
|
||||
/// the received metadata through the \a ClientContext.
|
||||
void ReadInitialMetadata(void* tag) override {
|
||||
CHECK(started_);
|
||||
CHECK(!context_->initial_metadata_received_);
|
||||
ABSL_CHECK(started_);
|
||||
ABSL_CHECK(!context_->initial_metadata_received_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -383,27 +386,27 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
|
|||
}
|
||||
|
||||
void Write(const W& msg, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
write_ops_.set_output_tag(tag);
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(write_ops_.SendMessage(msg).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
write_ops_.set_output_tag(tag);
|
||||
if (options.is_last_message()) {
|
||||
options.set_buffer_hint();
|
||||
write_ops_.ClientSendClose();
|
||||
}
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void WritesDone(void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
write_ops_.set_output_tag(tag);
|
||||
write_ops_.ClientSendClose();
|
||||
call_.PerformOps(&write_ops_);
|
||||
|
@ -417,7 +420,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
|
|||
/// - attempts to fill in the \a response parameter passed to this class's
|
||||
/// constructor with the server's response message.
|
||||
void Finish(grpc::Status* status, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
finish_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -437,7 +440,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
|
|||
if (start) {
|
||||
StartCallInternal(tag);
|
||||
} else {
|
||||
CHECK(tag == nullptr);
|
||||
ABSL_CHECK(tag == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,7 +520,7 @@ class ClientAsyncReaderWriter final
|
|||
public:
|
||||
// always allocated against a call arena, no memory free required
|
||||
static void operator delete(void* /*ptr*/, std::size_t size) {
|
||||
CHECK_EQ(size, sizeof(ClientAsyncReaderWriter));
|
||||
ABSL_CHECK_EQ(size, sizeof(ClientAsyncReaderWriter));
|
||||
}
|
||||
|
||||
// This operator should never be called as the memory should be freed as part
|
||||
|
@ -525,10 +528,10 @@ class ClientAsyncReaderWriter final
|
|||
// delete to the operator new so that some compilers will not complain (see
|
||||
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
|
||||
// there are no tests catching the compiler warning.
|
||||
static void operator delete(void*, void*) { CHECK(false); }
|
||||
static void operator delete(void*, void*) { ABSL_CHECK(false); }
|
||||
|
||||
void StartCall(void* tag) override {
|
||||
CHECK(!started_);
|
||||
ABSL_CHECK(!started_);
|
||||
started_ = true;
|
||||
StartCallInternal(tag);
|
||||
}
|
||||
|
@ -541,8 +544,8 @@ class ClientAsyncReaderWriter final
|
|||
/// is updated with it, and then the receiving initial metadata can
|
||||
/// be accessed through this \a ClientContext.
|
||||
void ReadInitialMetadata(void* tag) override {
|
||||
CHECK(started_);
|
||||
CHECK(!context_->initial_metadata_received_);
|
||||
ABSL_CHECK(started_);
|
||||
ABSL_CHECK(!context_->initial_metadata_received_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -550,7 +553,7 @@ class ClientAsyncReaderWriter final
|
|||
}
|
||||
|
||||
void Read(R* msg, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
read_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
read_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -560,27 +563,27 @@ class ClientAsyncReaderWriter final
|
|||
}
|
||||
|
||||
void Write(const W& msg, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
write_ops_.set_output_tag(tag);
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(write_ops_.SendMessage(msg).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
write_ops_.set_output_tag(tag);
|
||||
if (options.is_last_message()) {
|
||||
options.set_buffer_hint();
|
||||
write_ops_.ClientSendClose();
|
||||
}
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void WritesDone(void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
write_ops_.set_output_tag(tag);
|
||||
write_ops_.ClientSendClose();
|
||||
call_.PerformOps(&write_ops_);
|
||||
|
@ -591,7 +594,7 @@ class ClientAsyncReaderWriter final
|
|||
/// - the \a ClientContext associated with this call is updated with
|
||||
/// possible initial and trailing metadata sent from the server.
|
||||
void Finish(grpc::Status* status, void* tag) override {
|
||||
CHECK(started_);
|
||||
ABSL_CHECK(started_);
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
finish_ops_.RecvInitialMetadata(context_);
|
||||
|
@ -608,7 +611,7 @@ class ClientAsyncReaderWriter final
|
|||
if (start) {
|
||||
StartCallInternal(tag);
|
||||
} else {
|
||||
CHECK(tag == nullptr);
|
||||
ABSL_CHECK(tag == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,7 +711,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
|
|||
/// - The initial metadata that will be sent to the client from this op will
|
||||
/// be taken from the \a ServerContext associated with the call.
|
||||
void SendInitialMetadata(void* tag) override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
|
||||
|
@ -767,7 +770,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
|
|||
/// gRPC doesn't take ownership or a reference to \a status, so it is safe to
|
||||
/// to deallocate once FinishWithError returns.
|
||||
void FinishWithError(const grpc::Status& status, void* tag) override {
|
||||
CHECK(!status.ok());
|
||||
ABSL_CHECK(!status.ok());
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
|
||||
|
@ -857,7 +860,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
|
|||
///
|
||||
/// \param[in] tag Tag identifying this request.
|
||||
void SendInitialMetadata(void* tag) override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
|
||||
|
@ -873,7 +876,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
|
|||
write_ops_.set_output_tag(tag);
|
||||
EnsureInitialMetadataSent(&write_ops_);
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(write_ops_.SendMessage(msg).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
|
@ -885,7 +888,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
|
|||
|
||||
EnsureInitialMetadataSent(&write_ops_);
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
|
@ -904,7 +907,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
|
|||
write_ops_.set_output_tag(tag);
|
||||
EnsureInitialMetadataSent(&write_ops_);
|
||||
options.set_buffer_hint();
|
||||
CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
@ -1023,7 +1026,7 @@ class ServerAsyncReaderWriter final
|
|||
///
|
||||
/// \param[in] tag Tag identifying this request.
|
||||
void SendInitialMetadata(void* tag) override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
|
||||
|
@ -1045,7 +1048,7 @@ class ServerAsyncReaderWriter final
|
|||
write_ops_.set_output_tag(tag);
|
||||
EnsureInitialMetadataSent(&write_ops_);
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(write_ops_.SendMessage(msg).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
|
@ -1055,7 +1058,7 @@ class ServerAsyncReaderWriter final
|
|||
options.set_buffer_hint();
|
||||
}
|
||||
EnsureInitialMetadataSent(&write_ops_);
|
||||
CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
|
@ -1075,7 +1078,7 @@ class ServerAsyncReaderWriter final
|
|||
write_ops_.set_output_tag(tag);
|
||||
EnsureInitialMetadataSent(&write_ops_);
|
||||
options.set_buffer_hint();
|
||||
CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
|
||||
write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
|
|
@ -19,10 +19,7 @@
|
|||
#ifndef GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H
|
||||
#define GRPCPP_SUPPORT_ASYNC_UNARY_CALL_H
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/client_context.h>
|
||||
#include <grpcpp/impl/call.h>
|
||||
#include <grpcpp/impl/call_op_set.h>
|
||||
|
@ -32,6 +29,8 @@
|
|||
#include <grpcpp/server_context.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
namespace grpc {
|
||||
|
||||
// Forward declaration for use in Helper class
|
||||
|
@ -132,7 +131,7 @@ class ClientAsyncResponseReaderHelper {
|
|||
new (grpc_call_arena_alloc(call, sizeof(SingleBufType))) SingleBufType;
|
||||
*single_buf_ptr = single_buf;
|
||||
// TODO(ctiller): don't assert
|
||||
CHECK(single_buf->SendMessage(request).ok());
|
||||
ABSL_CHECK(single_buf->SendMessage(request).ok());
|
||||
single_buf->ClientSendClose();
|
||||
|
||||
// The purpose of the following functions is to type-erase the actual
|
||||
|
@ -222,7 +221,7 @@ class ClientAsyncResponseReader final
|
|||
public:
|
||||
// always allocated against a call arena, no memory free required
|
||||
static void operator delete(void* /*ptr*/, std::size_t size) {
|
||||
CHECK_EQ(size, sizeof(ClientAsyncResponseReader));
|
||||
ABSL_CHECK_EQ(size, sizeof(ClientAsyncResponseReader));
|
||||
}
|
||||
|
||||
// This operator should never be called as the memory should be freed as part
|
||||
|
@ -230,10 +229,10 @@ class ClientAsyncResponseReader final
|
|||
// delete to the operator new so that some compilers will not complain (see
|
||||
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
|
||||
// there are no tests catching the compiler warning.
|
||||
static void operator delete(void*, void*) { CHECK(false); }
|
||||
static void operator delete(void*, void*) { ABSL_CHECK(false); }
|
||||
|
||||
void StartCall() override {
|
||||
DCHECK(!started_);
|
||||
ABSL_DCHECK(!started_);
|
||||
started_ = true;
|
||||
internal::ClientAsyncResponseReaderHelper::StartCall(context_, single_buf_);
|
||||
}
|
||||
|
@ -245,8 +244,8 @@ class ClientAsyncResponseReader final
|
|||
/// - the \a ClientContext associated with this call is updated with
|
||||
/// possible initial and trailing metadata sent from the server.
|
||||
void ReadInitialMetadata(void* tag) override {
|
||||
DCHECK(started_);
|
||||
DCHECK(!context_->initial_metadata_received_);
|
||||
ABSL_DCHECK(started_);
|
||||
ABSL_DCHECK(!context_->initial_metadata_received_);
|
||||
read_initial_metadata_(context_, &call_, single_buf_, tag);
|
||||
initial_metadata_read_ = true;
|
||||
}
|
||||
|
@ -257,7 +256,7 @@ class ClientAsyncResponseReader final
|
|||
/// - the \a ClientContext associated with this call is updated with
|
||||
/// possible initial and trailing metadata sent from the server.
|
||||
void Finish(R* msg, grpc::Status* status, void* tag) override {
|
||||
DCHECK(started_);
|
||||
ABSL_DCHECK(started_);
|
||||
finish_(context_, &call_, initial_metadata_read_, single_buf_, &finish_buf_,
|
||||
static_cast<void*>(msg), status, tag);
|
||||
}
|
||||
|
@ -306,7 +305,7 @@ class ServerAsyncResponseWriter final
|
|||
///
|
||||
/// \param[in] tag Tag identifying this request.
|
||||
void SendInitialMetadata(void* tag) override {
|
||||
CHECK(!ctx_->sent_initial_metadata_);
|
||||
ABSL_CHECK(!ctx_->sent_initial_metadata_);
|
||||
|
||||
meta_buf_.set_output_tag(tag);
|
||||
meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_,
|
||||
|
@ -375,7 +374,7 @@ class ServerAsyncResponseWriter final
|
|||
/// deallocate them once the Finish operation is complete (i.e. a result
|
||||
/// arrives in the completion queue).
|
||||
void FinishWithError(const grpc::Status& status, void* tag) {
|
||||
CHECK(!status.ok());
|
||||
ABSL_CHECK(!status.ok());
|
||||
finish_buf_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_,
|
||||
|
|
|
@ -19,16 +19,15 @@
|
|||
#ifndef GRPCPP_SUPPORT_BYTE_BUFFER_H
|
||||
#define GRPCPP_SUPPORT_BYTE_BUFFER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/byte_buffer.h>
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/serialization_traits.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/slice.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class ServerInterface;
|
||||
|
@ -59,7 +58,7 @@ class GrpcByteBufferPeer;
|
|||
/// A sequence of bytes.
|
||||
class ByteBuffer final {
|
||||
public:
|
||||
/// Constuct an empty buffer.
|
||||
/// Construct an empty buffer.
|
||||
ByteBuffer() : buffer_(nullptr) {}
|
||||
|
||||
/// Construct buffer from \a slices, of which there are \a nslices.
|
||||
|
|
|
@ -19,19 +19,19 @@
|
|||
#ifndef GRPCPP_SUPPORT_CALLBACK_COMMON_H
|
||||
#define GRPCPP_SUPPORT_CALLBACK_COMMON_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/impl/grpc_types.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpcpp/impl/call.h>
|
||||
#include <grpcpp/impl/codegen/channel_interface.h>
|
||||
#include <grpcpp/impl/completion_queue_tag.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
#include <grpcpp/support/global_callback_hook.h>
|
||||
#include <grpcpp/support/status.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
|
||||
namespace grpc {
|
||||
namespace internal {
|
||||
|
||||
|
@ -73,7 +73,7 @@ class CallbackWithStatusTag : public grpc_completion_queue_functor {
|
|||
public:
|
||||
// always allocated against a call arena, no memory free required
|
||||
static void operator delete(void* /*ptr*/, std::size_t size) {
|
||||
CHECK_EQ(size, sizeof(CallbackWithStatusTag));
|
||||
ABSL_CHECK_EQ(size, sizeof(CallbackWithStatusTag));
|
||||
}
|
||||
|
||||
// This operator should never be called as the memory should be freed as part
|
||||
|
@ -81,7 +81,7 @@ class CallbackWithStatusTag : public grpc_completion_queue_functor {
|
|||
// delete to the operator new so that some compilers will not complain (see
|
||||
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
|
||||
// there are no tests catching the compiler warning.
|
||||
static void operator delete(void*, void*) { CHECK(false); }
|
||||
static void operator delete(void*, void*) { ABSL_CHECK(false); }
|
||||
|
||||
CallbackWithStatusTag(grpc_call* call, std::function<void(Status)> f,
|
||||
CompletionQueueTag* ops)
|
||||
|
@ -120,14 +120,25 @@ class CallbackWithStatusTag : public grpc_completion_queue_functor {
|
|||
// The tag was swallowed
|
||||
return;
|
||||
}
|
||||
CHECK(ignored == ops_);
|
||||
ABSL_CHECK(ignored == ops_);
|
||||
|
||||
// Last use of func_ or status_, so ok to move them out
|
||||
auto func = std::move(func_);
|
||||
auto status = std::move(status_);
|
||||
func_ = nullptr; // reset to clear this out for sure
|
||||
status_ = Status(); // reset to clear this out for sure
|
||||
CatchingCallback(std::move(func), std::move(status));
|
||||
GetGlobalCallbackHook()->RunCallback(
|
||||
call_, [func = std::move(func), status = std::move(status)]() {
|
||||
#if GRPC_ALLOW_EXCEPTIONS
|
||||
try {
|
||||
func(status);
|
||||
} catch (...) {
|
||||
// nothing to return or change here, just don't crash the library
|
||||
}
|
||||
#else // GRPC_ALLOW_EXCEPTIONS
|
||||
func(status);
|
||||
#endif // GRPC_ALLOW_EXCEPTIONS
|
||||
});
|
||||
grpc_call_unref(call_);
|
||||
}
|
||||
};
|
||||
|
@ -139,7 +150,7 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
|
|||
public:
|
||||
// always allocated against a call arena, no memory free required
|
||||
static void operator delete(void* /*ptr*/, std::size_t size) {
|
||||
CHECK_EQ(size, sizeof(CallbackWithSuccessTag));
|
||||
ABSL_CHECK_EQ(size, sizeof(CallbackWithSuccessTag));
|
||||
}
|
||||
|
||||
// This operator should never be called as the memory should be freed as part
|
||||
|
@ -147,7 +158,7 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
|
|||
// delete to the operator new so that some compilers will not complain (see
|
||||
// https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
|
||||
// there are no tests catching the compiler warning.
|
||||
static void operator delete(void*, void*) { CHECK(false); }
|
||||
static void operator delete(void*, void*) { ABSL_CHECK(false); }
|
||||
|
||||
CallbackWithSuccessTag() : call_(nullptr) {}
|
||||
|
||||
|
@ -164,7 +175,7 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
|
|||
// callbacks.
|
||||
void Set(grpc_call* call, std::function<void(bool)> f,
|
||||
CompletionQueueTag* ops, bool can_inline) {
|
||||
CHECK_EQ(call_, nullptr);
|
||||
ABSL_CHECK_EQ(call_, nullptr);
|
||||
grpc_call_ref(call);
|
||||
call_ = call;
|
||||
func_ = std::move(f);
|
||||
|
@ -210,11 +221,21 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor {
|
|||
#endif
|
||||
bool do_callback = ops_->FinalizeResult(&ignored, &ok);
|
||||
#ifndef NDEBUG
|
||||
DCHECK(ignored == ops);
|
||||
ABSL_DCHECK(ignored == ops);
|
||||
#endif
|
||||
|
||||
if (do_callback) {
|
||||
CatchingCallback(func_, ok);
|
||||
GetGlobalCallbackHook()->RunCallback(call_, [this, ok]() {
|
||||
#if GRPC_ALLOW_EXCEPTIONS
|
||||
try {
|
||||
func_(ok);
|
||||
} catch (...) {
|
||||
// nothing to return or change here, just don't crash the library
|
||||
}
|
||||
#else // GRPC_ALLOW_EXCEPTIONS
|
||||
func_(ok);
|
||||
#endif // GRPC_ALLOW_EXCEPTIONS
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
#ifndef GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_H
|
||||
#define GRPCPP_SUPPORT_CHANNEL_ARGUMENTS_H
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include <grpc/compression.h>
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpcpp/resource_quota.h>
|
||||
#include <grpcpp/support/config.h>
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
namespace grpc {
|
||||
class ChannelCredentials;
|
||||
namespace testing {
|
||||
|
@ -84,8 +84,10 @@ class ChannelArguments {
|
|||
void SetMaxSendMessageSize(int size);
|
||||
|
||||
/// Set LB policy name.
|
||||
/// Note that if the name resolver returns only balancer addresses, the
|
||||
/// grpclb LB policy will be used, regardless of what is specified here.
|
||||
/// Note that this API implicitly provides an empty config for the
|
||||
/// specified LB policy, so it cannot be used for any policy with
|
||||
/// required configuration parameters. For those cases, set the LB
|
||||
/// policy via the service config instead.
|
||||
void SetLoadBalancingPolicyName(const std::string& lb_policy_name);
|
||||
|
||||
/// Set service config in JSON form.
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue