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