From eb8af70ee0b0ae359c9fcb87ecaf577f0e51cf38 Mon Sep 17 00:00:00 2001 From: Vignesh Babu Date: Wed, 2 Feb 2022 12:48:47 -0800 Subject: [PATCH] Creating an event_engine_common library that contains code which all event engine implementations can depend on (#28765) * creating an event_engine_common library that contains code which all event engine implementations can depend on * adding event_engine_common dependency * regenerate projects * Automated change: Fix sanity tests * renaming file * regenerate projects Co-authored-by: Vignesh2208 --- BUILD | 12 ++++++ CMakeLists.txt | 2 + Makefile | 2 + build_autogenerated.yaml | 2 + config.m4 | 1 + config.w32 | 1 + gRPC-Core.podspec | 1 + grpc.gemspec | 1 + grpc.gyp | 2 + package.xml | 1 + src/core/lib/event_engine/event_engine.cc | 13 ------- src/core/lib/event_engine/resolved_address.cc | 39 +++++++++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core.internal | 1 + 15 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 src/core/lib/event_engine/resolved_address.cc diff --git a/BUILD b/BUILD index 791418f1aaf..198aee7109f 100644 --- a/BUILD +++ b/BUILD @@ -1746,6 +1746,17 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "event_engine_common", + srcs = [ + "src/core/lib/event_engine/resolved_address.cc", + ], + deps = [ + "event_engine_base_hdrs", + "gpr_base", + ], +) + grpc_cc_library( name = "event_engine_base", srcs = [ @@ -2108,6 +2119,7 @@ grpc_cc_library( "dual_ref_counted", "error", "event_engine_base", + "event_engine_common", "exec_ctx", "gpr_base", "gpr_codegen", diff --git a/CMakeLists.txt b/CMakeLists.txt index dd20ccb2e56..95680d07af4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1974,6 +1974,7 @@ add_library(grpc src/core/lib/event_engine/default_event_engine_factory.cc src/core/lib/event_engine/event_engine.cc src/core/lib/event_engine/memory_allocator.cc + src/core/lib/event_engine/resolved_address.cc src/core/lib/event_engine/sockaddr.cc src/core/lib/http/format_request.cc src/core/lib/http/httpcli.cc @@ -2625,6 +2626,7 @@ add_library(grpc_unsecure src/core/lib/event_engine/default_event_engine_factory.cc src/core/lib/event_engine/event_engine.cc src/core/lib/event_engine/memory_allocator.cc + src/core/lib/event_engine/resolved_address.cc src/core/lib/event_engine/sockaddr.cc src/core/lib/http/format_request.cc src/core/lib/http/httpcli.cc diff --git a/Makefile b/Makefile index d458f340df3..91072b23b5c 100644 --- a/Makefile +++ b/Makefile @@ -1450,6 +1450,7 @@ LIBGRPC_SRC = \ src/core/lib/event_engine/default_event_engine_factory.cc \ src/core/lib/event_engine/event_engine.cc \ src/core/lib/event_engine/memory_allocator.cc \ + src/core/lib/event_engine/resolved_address.cc \ src/core/lib/event_engine/sockaddr.cc \ src/core/lib/http/format_request.cc \ src/core/lib/http/httpcli.cc \ @@ -1948,6 +1949,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/event_engine/default_event_engine_factory.cc \ src/core/lib/event_engine/event_engine.cc \ src/core/lib/event_engine/memory_allocator.cc \ + src/core/lib/event_engine/resolved_address.cc \ src/core/lib/event_engine/sockaddr.cc \ src/core/lib/http/format_request.cc \ src/core/lib/http/httpcli.cc \ diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 53e65a78529..d3bae1c87c6 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -1485,6 +1485,7 @@ libs: - src/core/lib/event_engine/default_event_engine_factory.cc - src/core/lib/event_engine/event_engine.cc - src/core/lib/event_engine/memory_allocator.cc + - src/core/lib/event_engine/resolved_address.cc - src/core/lib/event_engine/sockaddr.cc - src/core/lib/http/format_request.cc - src/core/lib/http/httpcli.cc @@ -2306,6 +2307,7 @@ libs: - src/core/lib/event_engine/default_event_engine_factory.cc - src/core/lib/event_engine/event_engine.cc - src/core/lib/event_engine/memory_allocator.cc + - src/core/lib/event_engine/resolved_address.cc - src/core/lib/event_engine/sockaddr.cc - src/core/lib/http/format_request.cc - src/core/lib/http/httpcli.cc diff --git a/config.m4 b/config.m4 index 1e48fb29070..b6aeb423042 100644 --- a/config.m4 +++ b/config.m4 @@ -468,6 +468,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/event_engine/default_event_engine_factory.cc \ src/core/lib/event_engine/event_engine.cc \ src/core/lib/event_engine/memory_allocator.cc \ + src/core/lib/event_engine/resolved_address.cc \ src/core/lib/event_engine/sockaddr.cc \ src/core/lib/gpr/alloc.cc \ src/core/lib/gpr/atm.cc \ diff --git a/config.w32 b/config.w32 index 8185fa9e77a..34e21625212 100644 --- a/config.w32 +++ b/config.w32 @@ -434,6 +434,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\event_engine\\default_event_engine_factory.cc " + "src\\core\\lib\\event_engine\\event_engine.cc " + "src\\core\\lib\\event_engine\\memory_allocator.cc " + + "src\\core\\lib\\event_engine\\resolved_address.cc " + "src\\core\\lib\\event_engine\\sockaddr.cc " + "src\\core\\lib\\gpr\\alloc.cc " + "src\\core\\lib\\gpr\\atm.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 377fb5b6e7a..f596f683fe2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1026,6 +1026,7 @@ Pod::Spec.new do |s| 'src/core/lib/event_engine/event_engine.cc', 'src/core/lib/event_engine/event_engine_factory.h', 'src/core/lib/event_engine/memory_allocator.cc', + 'src/core/lib/event_engine/resolved_address.cc', 'src/core/lib/event_engine/sockaddr.cc', 'src/core/lib/event_engine/sockaddr.h', 'src/core/lib/gpr/alloc.cc', diff --git a/grpc.gemspec b/grpc.gemspec index b6a79715d6c..004bf19fd75 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -945,6 +945,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/event_engine/event_engine.cc ) s.files += %w( src/core/lib/event_engine/event_engine_factory.h ) s.files += %w( src/core/lib/event_engine/memory_allocator.cc ) + s.files += %w( src/core/lib/event_engine/resolved_address.cc ) s.files += %w( src/core/lib/event_engine/sockaddr.cc ) s.files += %w( src/core/lib/event_engine/sockaddr.h ) s.files += %w( src/core/lib/gpr/alloc.cc ) diff --git a/grpc.gyp b/grpc.gyp index b63c1e20673..de5439878ae 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -900,6 +900,7 @@ 'src/core/lib/event_engine/default_event_engine_factory.cc', 'src/core/lib/event_engine/event_engine.cc', 'src/core/lib/event_engine/memory_allocator.cc', + 'src/core/lib/event_engine/resolved_address.cc', 'src/core/lib/event_engine/sockaddr.cc', 'src/core/lib/http/format_request.cc', 'src/core/lib/http/httpcli.cc', @@ -1370,6 +1371,7 @@ 'src/core/lib/event_engine/default_event_engine_factory.cc', 'src/core/lib/event_engine/event_engine.cc', 'src/core/lib/event_engine/memory_allocator.cc', + 'src/core/lib/event_engine/resolved_address.cc', 'src/core/lib/event_engine/sockaddr.cc', 'src/core/lib/http/format_request.cc', 'src/core/lib/http/httpcli.cc', diff --git a/package.xml b/package.xml index 1242c9783c7..001d97b4ea3 100644 --- a/package.xml +++ b/package.xml @@ -925,6 +925,7 @@ + diff --git a/src/core/lib/event_engine/event_engine.cc b/src/core/lib/event_engine/event_engine.cc index b0488da74df..31b25a2c9e5 100644 --- a/src/core/lib/event_engine/event_engine.cc +++ b/src/core/lib/event_engine/event_engine.cc @@ -23,19 +23,6 @@ namespace grpc_event_engine { namespace experimental { -EventEngine::ResolvedAddress::ResolvedAddress(const sockaddr* address, - socklen_t size) - : size_(size) { - GPR_ASSERT(size <= sizeof(address_)); - memcpy(&address_, address, size); -} - -const struct sockaddr* EventEngine::ResolvedAddress::address() const { - return reinterpret_cast(address_); -} - -socklen_t EventEngine::ResolvedAddress::size() const { return size_; } - namespace { const std::function()>* g_event_engine_factory = nullptr; diff --git a/src/core/lib/event_engine/resolved_address.cc b/src/core/lib/event_engine/resolved_address.cc new file mode 100644 index 00000000000..0623e6317f2 --- /dev/null +++ b/src/core/lib/event_engine/resolved_address.cc @@ -0,0 +1,39 @@ +// Copyright 2021 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. +#include + +#include +#include +#include + +#include "src/core/lib/gprpp/sync.h" + +namespace grpc_event_engine { +namespace experimental { + +EventEngine::ResolvedAddress::ResolvedAddress(const sockaddr* address, + socklen_t size) + : size_(size) { + GPR_ASSERT(size <= sizeof(address_)); + memcpy(&address_, address, size); +} + +const struct sockaddr* EventEngine::ResolvedAddress::address() const { + return reinterpret_cast(address_); +} + +socklen_t EventEngine::ResolvedAddress::size() const { return size_; } + +} // namespace experimental +} // namespace grpc_event_engine diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 637f5ff4dd3..ea39ff10c82 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -443,6 +443,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/event_engine/default_event_engine_factory.cc', 'src/core/lib/event_engine/event_engine.cc', 'src/core/lib/event_engine/memory_allocator.cc', + 'src/core/lib/event_engine/resolved_address.cc', 'src/core/lib/event_engine/sockaddr.cc', 'src/core/lib/gpr/alloc.cc', 'src/core/lib/gpr/atm.cc', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 083713f7622..81b882f0d65 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1924,6 +1924,7 @@ src/core/lib/event_engine/default_event_engine_factory.cc \ src/core/lib/event_engine/event_engine.cc \ src/core/lib/event_engine/event_engine_factory.h \ src/core/lib/event_engine/memory_allocator.cc \ +src/core/lib/event_engine/resolved_address.cc \ src/core/lib/event_engine/sockaddr.cc \ src/core/lib/event_engine/sockaddr.h \ src/core/lib/gpr/alloc.cc \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 041ba1576ad..b3f04fdc547 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1720,6 +1720,7 @@ src/core/lib/event_engine/default_event_engine_factory.cc \ src/core/lib/event_engine/event_engine.cc \ src/core/lib/event_engine/event_engine_factory.h \ src/core/lib/event_engine/memory_allocator.cc \ +src/core/lib/event_engine/resolved_address.cc \ src/core/lib/event_engine/sockaddr.cc \ src/core/lib/event_engine/sockaddr.h \ src/core/lib/gpr/README.md \