#include <event_engine.h>
Classes | |
struct | ReadArgs |
struct | WriteArgs |
Public Member Functions | |
virtual const ResolvedAddress & | GetLocalAddress () const =0 |
virtual const ResolvedAddress & | GetPeerAddress () const =0 |
virtual void | Read (std::function< void(absl::Status)> on_read, SliceBuffer *buffer, const ReadArgs *args)=0 |
virtual void | Write (std::function< void(absl::Status)> on_writable, SliceBuffer *data, const WriteArgs *args)=0 |
virtual | ~Endpoint ()=default |
One end of a connection between a gRPC client and server. Endpoints are created when connections are established, and Endpoint operations are gRPC's primary means of communication.
Endpoints must use the provided MemoryAllocator for all data buffer memory allocations. gRPC allows applications to set memory constraints per Channel or Server, and the implementation depends on all dynamic memory allocation being handled by the quota system.
Definition at line 141 of file event_engine.h.
|
virtualdefault |
Shuts down all connections and invokes all pending read or write callbacks with an error status.
|
pure virtual |
|
pure virtual |
Returns an address in the format described in DNSResolver. The returned values are expected to remain valid for the life of the Endpoint.
Implemented in grpc_event_engine::experimental::IomgrEventEngine::IomgrEndpoint, and grpc_event_engine::experimental::PosixOracleEndpoint.
|
pure virtual |
Reads data from the Endpoint.
When data is available on the connection, that data is moved into the buffer, and the on_read callback is called. The caller must ensure that the callback has access to the buffer when executed later. Ownership of the buffer is not transferred. Valid slices may be placed into the buffer even if the callback is invoked with a non-OK Status.
There can be at most one outstanding read per Endpoint at any given time. An outstanding read is one in which the on_read callback has not yet been executed for some previous call to Read. If an attempt is made to call Read while a previous read is still outstanding, the EventEngine must abort.
For failed read operations, implementations should pass the appropriate statuses to on_read. For example, callbacks might expect to receive CANCELLED on endpoint shutdown.
Implemented in grpc_event_engine::experimental::IomgrEventEngine::IomgrEndpoint, and grpc_event_engine::experimental::PosixOracleEndpoint.
|
pure virtual |
Writes data out on the connection.
on_writable is called when the connection is ready for more data. The Slices within the data buffer may be mutated at will by the Endpoint until on_writable is called. The data SliceBuffer will remain valid after calling Write, but its state is otherwise undefined. All bytes in data must have been written before calling on_writable unless an error has occurred.
There can be at most one outstanding write per Endpoint at any given time. An outstanding write is one in which the on_writable callback has not yet been executed for some previous call to Write. If an attempt is made to call Write while a previous write is still outstanding, the EventEngine must abort.
For failed write operations, implementations should pass the appropriate statuses to on_writable. For example, callbacks might expect to receive CANCELLED on endpoint shutdown.
Implemented in grpc_event_engine::experimental::IomgrEventEngine::IomgrEndpoint, and grpc_event_engine::experimental::PosixOracleEndpoint.