class Endpoint
Defined at line 173 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/event_engine.h
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.
Public Methods
bool Read (absl::AnyInvocable<void (absl::Status)> on_read, SliceBuffer * buffer, const ReadArgs * args)
Reads data from the Endpoint.
When data is available on the connection, that data is moved into the
If the read succeeds immediately, it returns true and the
callback is not executed. Otherwise it returns false and the
callback executes asynchronously when the read completes. The
caller must ensure that the callback has access to the buffer when it
executes. 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
callback has
not yet been executed for some previous call to
If an attempt
is made to call
while a previous read is still outstanding, the
must abort.
For failed read operations, implementations should pass the appropriate
statuses to
For example, callbacks might expect to receive
CANCELLED on endpoint shutdown.
bool Write (absl::AnyInvocable<void (absl::Status)> on_writable, SliceBuffer * data, const WriteArgs * args)
Writes data out on the connection.
If the write succeeds immediately, it returns true and the
callback is not executed. Otherwise it returns false and
the
callback is called asynchronously when the connection
is ready for more data. The Slices within the
buffer may be
mutated at will by the Endpoint until
is called. The
SliceBuffer will remain valid after calling
but its state
is otherwise undefined. All bytes in
must have been written
before calling
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
callback
has not yet been executed for some previous call to
If an
attempt is made to call
while a previous write is still
outstanding, the
must abort.
For failed write operations, implementations should pass the appropriate
statuses to
For example, callbacks might expect to
receive CANCELLED on endpoint shutdown.
const ResolvedAddress & GetPeerAddress ()
Returns an address in the format described in DNSResolver. The returned
values are expected to remain valid for the life of the Endpoint.
const ResolvedAddress & GetLocalAddress ()
void ~Endpoint ()
Shuts down all connections and invokes all pending read or write
callbacks with an error status.
Defined at line 177 of file ../../third_party/grpc-migrating/src/include/grpc/event_engine/event_engine.h