1 // Copyright 2021 The gRPC Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 #ifndef GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_ENDPOINT_H 15 #define GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_ENDPOINT_H 16 17 #include <grpc/support/port_platform.h> 18 19 #ifdef GRPC_USE_EVENT_ENGINE 20 #include <grpc/event_engine/event_engine.h> 21 22 #include "src/core/lib/iomgr/endpoint.h" 23 #include "src/core/lib/iomgr/resource_quota.h" 24 25 struct grpc_event_engine_endpoint { 26 grpc_endpoint base; 27 std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint> 28 endpoint; 29 std::string peer_address; 30 std::string local_address; 31 std::aligned_storage< 32 sizeof(grpc_event_engine::experimental::SliceBuffer), 33 alignof(grpc_event_engine::experimental::SliceBuffer)>::type read_buffer; 34 std::aligned_storage< 35 sizeof(grpc_event_engine::experimental::SliceBuffer), 36 alignof(grpc_event_engine::experimental::SliceBuffer)>::type write_buffer; 37 }; 38 39 /// Creates an internal grpc_endpoint struct from an EventEngine Endpoint. 40 /// Server code needs to create grpc_endpoints after the EventEngine has made 41 /// connections. 42 grpc_event_engine_endpoint* grpc_tcp_server_endpoint_create( 43 std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint> ee); 44 45 /// Creates a new internal grpc_endpoint struct, when no EventEngine Endpoint 46 /// has yet been created. This is used in client code before connections are 47 /// established. Takes ownership of the slice_allocator. 48 grpc_endpoint* grpc_tcp_create(const grpc_channel_args* channel_args, 49 absl::string_view peer_address); 50 51 #endif 52 #endif // GRPC_CORE_LIB_IOMGR_EVENT_ENGINE_ENDPOINT_H 53