GRPC C++  1.66.0
Data Structures | Public Member Functions
grpc_event_engine::experimental::EventEngine::Endpoint Class Referenceabstract

One end of a connection between a gRPC client and server. More...

#include <event_engine.h>

Data Structures

struct  ReadArgs
 A struct representing optional arguments that may be provided to an EventEngine Endpoint Read API call. More...
 
struct  WriteArgs
 A struct representing optional arguments that may be provided to an EventEngine Endpoint Write API call. More...
 

Public Member Functions

virtual ~Endpoint ()=default
 Shuts down all connections and invokes all pending read or write callbacks with an error status. More...
 
virtual bool Read (absl::AnyInvocable< void(absl::Status)> on_read, SliceBuffer *buffer, const ReadArgs *args)=0
 Reads data from the Endpoint. More...
 
virtual bool Write (absl::AnyInvocable< void(absl::Status)> on_writable, SliceBuffer *data, const WriteArgs *args)=0
 Writes data out on the connection. More...
 
virtual const ResolvedAddressGetPeerAddress () const =0
 Returns an address in the format described in DNSResolver. More...
 
virtual const ResolvedAddressGetLocalAddress () const =0
 
- Public Member Functions inherited from grpc_event_engine::experimental::Extensible
virtual void * QueryExtension (absl::string_view)
 A method which allows users to query whether an implementation supports a specified extension. More...
 

Additional Inherited Members

- Protected Member Functions inherited from grpc_event_engine::experimental::Extensible
 ~Extensible ()=default
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~Endpoint()

virtual grpc_event_engine::experimental::EventEngine::Endpoint::~Endpoint ( )
virtualdefault

Shuts down all connections and invokes all pending read or write callbacks with an error status.

Member Function Documentation

◆ GetLocalAddress()

virtual const ResolvedAddress& grpc_event_engine::experimental::EventEngine::Endpoint::GetLocalAddress ( ) const
pure virtual

◆ GetPeerAddress()

virtual const ResolvedAddress& grpc_event_engine::experimental::EventEngine::Endpoint::GetPeerAddress ( ) const
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.

◆ Read()

virtual bool grpc_event_engine::experimental::EventEngine::Endpoint::Read ( absl::AnyInvocable< void(absl::Status)>  on_read,
SliceBuffer buffer,
const ReadArgs args 
)
pure virtual

Reads data from the Endpoint.

When data is available on the connection, that data is moved into the buffer. If the read succeeds immediately, it returns true and the on_read callback is not executed. Otherwise it returns false and the on_read 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 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.

◆ Write()

virtual bool grpc_event_engine::experimental::EventEngine::Endpoint::Write ( absl::AnyInvocable< void(absl::Status)>  on_writable,
SliceBuffer data,
const WriteArgs args 
)
pure virtual

Writes data out on the connection.

If the write succeeds immediately, it returns true and the on_writable callback is not executed. Otherwise it returns false and the on_writable callback is called asynchronously 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.


The documentation for this class was generated from the following file: