14 #ifndef GRPC_EVENT_ENGINE_EVENT_ENGINE_H
15 #define GRPC_EVENT_ENGINE_EVENT_ENGINE_H
22 #include "absl/status/status.h"
23 #include "absl/status/statusor.h"
24 #include "absl/time/time.h"
32 namespace experimental {
133 absl::Time deadline) = 0;
146 absl::Time deadline) = 0;
161 std::function<void(absl::StatusOr<std::unique_ptr<Endpoint>>)>;
218 absl::Time deadline) = 0;
237 std::function<void(absl::StatusOr<std::vector<ResolvedAddress>>)>;
240 std::function<void(absl::StatusOr<std::vector<SRVRecord>>)>;
257 absl::string_view address,
258 absl::string_view default_port,
259 absl::Time deadline) = 0;
265 absl::string_view name,
266 absl::Time deadline) = 0;
272 absl::string_view name,
273 absl::Time deadline) = 0;
A set of parameters used to configure an endpoint, either when initiating a new connection on the cli...
Definition: endpoint_config.h:35
The DNSResolver that provides asynchronous resolution.
Definition: event_engine.h:221
std::function< void(absl::StatusOr< std::vector< SRVRecord > >)> LookupSRVCallback
Called with a collection of SRV records.
Definition: event_engine.h:240
virtual LookupTaskHandle LookupHostname(LookupHostnameCallback on_resolve, absl::string_view address, absl::string_view default_port, absl::Time deadline)=0
Asynchronously resolve an address.
virtual LookupTaskHandle LookupTXT(LookupTXTCallback on_resolve, absl::string_view name, absl::Time deadline)=0
Asynchronously perform a TXT record lookup.
virtual LookupTaskHandle LookupSRV(LookupSRVCallback on_resolve, absl::string_view name, absl::Time deadline)=0
Asynchronously perform an SRV record lookup.
std::function< void(absl::StatusOr< std::string >)> LookupTXTCallback
Called with the result of a TXT record lookup.
Definition: event_engine.h:242
std::function< void(absl::StatusOr< std::vector< ResolvedAddress > >)> LookupHostnameCallback
Called with the collection of sockaddrs that were resolved from a given target address.
Definition: event_engine.h:237
virtual void TryCancelLookup(LookupTaskHandle handle)=0
Cancel an asynchronous lookup operation.
virtual ~DNSResolver()=default
An Endpoint represents one end of a connection between a gRPC client and server.
Definition: event_engine.h:115
virtual void Write(Callback on_writable, SliceBuffer *data, absl::Time deadline)=0
Write data out on the connection.
virtual const ResolvedAddress * GetPeerAddress() const =0
These methods return an address in the format described in DNSResolver.
virtual const ResolvedAddress * GetLocalAddress() const =0
virtual void Read(Callback on_read, SliceBuffer *buffer, absl::Time deadline)=0
Read data from the Endpoint.
virtual ~Endpoint()=default
The Endpoint destructor is responsible for shutting down all connections and invoking all pending rea...
An EventEngine Listener listens for incoming connection requests from gRPC clients and initiates requ...
Definition: event_engine.h:165
virtual ~Listener()=default
virtual absl::StatusOr< int > Bind(const ResolvedAddress &addr)=0
Bind an address/port to this Listener.
virtual absl::Status Start()=0
std::function< void(std::unique_ptr< Endpoint >)> AcceptCallback
Called when the listener has accepted a new client connection.
Definition: event_engine.h:168
A thin wrapper around a platform-specific sockaddr type.
Definition: event_engine.h:92
static constexpr socklen_t MAX_SIZE_BYTES
Definition: event_engine.h:94
ResolvedAddress()=default
const struct sockaddr * address() const
ResolvedAddress(const sockaddr *address, socklen_t size)
ResolvedAddress(const ResolvedAddress &)=default
The EventEngine encapsulates all platform-specific behaviors related to low level network I/O,...
Definition: event_engine.h:74
virtual void Shutdown(Callback on_shutdown_complete)=0
Immediately run all callbacks with status indicating the shutdown.
virtual TaskHandle Run(Callback fn, RunOptions opts)=0
Run a callback as soon as possible.
virtual absl::StatusOr< std::unique_ptr< Listener > > CreateListener(Listener::AcceptCallback on_accept, Callback on_shutdown, const EndpointConfig &args, SliceAllocatorFactory slice_allocator_factory)=0
Factory method to create a network listener / server.
virtual void TryCancel(TaskHandle handle)=0
Immediately tries to cancel a callback.
virtual ~EventEngine()=default
virtual absl::Status Connect(OnConnectCallback on_connect, const ResolvedAddress &addr, const EndpointConfig &args, SliceAllocator slice_allocator, absl::Time deadline)=0
Creates a client network connection to a remote network listener.
virtual TaskHandle RunAt(absl::Time when, Callback fn, RunOptions opts)=0
Synonymous with scheduling an alarm to run at time when.
std::function< void(absl::StatusOr< std::unique_ptr< Endpoint > >)> OnConnectCallback
Called when a new connection is established.
Definition: event_engine.h:161
virtual absl::StatusOr< std::unique_ptr< DNSResolver > > GetDNSResolver()=0
Retrieves an instance of a DNSResolver.
std::function< void(absl::Status)> Callback
A basic callable function.
Definition: event_engine.h:80
virtual bool IsWorkerThread()=0
Definition: slice_allocator.h:67
Definition: slice_allocator.h:38
Definition: slice_allocator.h:32
::google::protobuf::util::Status Status
Definition: config_protobuf.h:91
std::shared_ptr< EventEngine > DefaultEventEngineFactory()
Definition: endpoint_config.h:24
A task handle for DNS Resolution requests.
Definition: event_engine.h:224
intptr_t key
Definition: event_engine.h:225
A DNS SRV record type.
Definition: event_engine.h:228
std::string host
Definition: event_engine.h:229
int priority
Definition: event_engine.h:231
int weight
Definition: event_engine.h:232
int port
Definition: event_engine.h:230
Intended for future expansion of Task run functionality.
Definition: event_engine.h:289
A callback handle, used to cancel a callback.
Definition: event_engine.h:82
intptr_t key
Definition: event_engine.h:83