1 // Copyright 2022 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_TEST_CORE_EVENT_ENGINE_UTIL_ABORTING_EVENT_ENGINE_H 15 #define GRPC_TEST_CORE_EVENT_ENGINE_UTIL_ABORTING_EVENT_ENGINE_H 16 17 #include <stdlib.h> 18 19 #include <memory> 20 21 #include "absl/functional/any_invocable.h" 22 #include "absl/status/status.h" 23 #include "absl/status/statusor.h" 24 25 #include <grpc/event_engine/endpoint_config.h> 26 #include <grpc/event_engine/event_engine.h> 27 #include <grpc/event_engine/memory_allocator.h> 28 #include <grpc/support/port_platform.h> 29 30 namespace grpc_event_engine { 31 namespace experimental { 32 33 class AbortingEventEngine : public EventEngine { Connect(OnConnectCallback,const ResolvedAddress &,const EndpointConfig &,MemoryAllocator,Duration)34 ConnectionHandle Connect(OnConnectCallback /* on_connect */, 35 const ResolvedAddress& /* addr */, 36 const EndpointConfig& /* args */, 37 MemoryAllocator /* memory_allocator */, 38 Duration /* timeout */) override { 39 abort(); 40 }; CancelConnect(ConnectionHandle)41 bool CancelConnect(ConnectionHandle /* handle */) override { abort(); } CreateListener(Listener::AcceptCallback,absl::AnyInvocable<void (absl::Status)>,const EndpointConfig &,std::unique_ptr<MemoryAllocatorFactory>)42 absl::StatusOr<std::unique_ptr<Listener>> CreateListener( 43 Listener::AcceptCallback /* on_accept */, 44 absl::AnyInvocable<void(absl::Status)> /* on_shutdown */, 45 const EndpointConfig& /* config */, 46 std::unique_ptr<MemoryAllocatorFactory> /* memory_allocator_factory */) 47 override { 48 abort(); 49 }; IsWorkerThread()50 bool IsWorkerThread() override { abort(); } GetDNSResolver(const DNSResolver::ResolverOptions &)51 absl::StatusOr<std::unique_ptr<DNSResolver>> GetDNSResolver( 52 const DNSResolver::ResolverOptions& /* options */) override { 53 abort(); 54 } Run(Closure *)55 void Run(Closure* /* closure */) override { abort(); } Run(absl::AnyInvocable<void ()>)56 void Run(absl::AnyInvocable<void()> /* closure */) override { abort(); } RunAfter(Duration,Closure *)57 TaskHandle RunAfter(Duration /* when */, Closure* /* closure */) override { 58 abort(); 59 } RunAfter(Duration,absl::AnyInvocable<void ()>)60 TaskHandle RunAfter(Duration /* when */, 61 absl::AnyInvocable<void()> /* closure */) override { 62 abort(); 63 } Cancel(TaskHandle)64 bool Cancel(TaskHandle /* handle */) override { abort(); } 65 }; 66 67 } // namespace experimental 68 } // namespace grpc_event_engine 69 70 #endif // GRPC_TEST_CORE_EVENT_ENGINE_UTIL_ABORTING_EVENT_ENGINE_H 71