Skip to content

TCallData

A class that manages the state of a generic RPC call.

DoWork() can be used in child threads to automatically progress the state of the call.

Subclassed by TExchangeCallData< ServiceType, RequestType, ResponseType >

template <class ServiceType, typename RequestType, typename ResponseType>
class TCallData

Methods

Public

TCallData

inline TCallData(ServiceType *Service, ServerCompletionQueue *CQueue,
AsyncAPIHandler TargetRPC, bool bReusable = false,
bool bAutoCreate = true)

Construct a new CallData object.

Parameters

  • Service (ServiceType)

  • CQueue (ServerCompletionQueue)

  • TargetRPC (AsyncAPIHandler)

  • bReusable (bool, default: false)

  • bAutoCreate (bool, default: true)


Create

inline void Create()

Create/setup the calldata instance.


Submit

inline void Submit()

Submit a response to the caller of the TargetRPC.


Reset

inline void Reset()

Reset the RPC state object so it can be reused again by another RPC in the future.


Finish

inline void Finish()

The RPC has been deleted so perform final cleanup.


CleanUp

inline void CleanUp()

clean up, both this object and any other objects owned by it


GetRequest

inline const RequestType &GetRequest()

Get the request associated with this RPC.


GetMutableResponse

inline ResponseType *GetMutableResponse()

Get a Response message that can be mutated in place.


SetResponse

inline void SetResponse(ResponseType *NewResponse)

Set the response message.

Parameters

  • NewResponse (ResponseType)

HasResponse

inline bool HasResponse()

Has the response message been set already.


IsReady

inline bool IsReady()

Returns whether the RPC is ready for processing.


DoWork

inline void DoWork()

Progress the state of the RPC.

Protected

CallStatus

enum CallStatus

An enum representing the possible states of the RPC.


AsyncAPIHandler

using AsyncAPIHandler =
void (ServiceType::*)(grpc::ServerContext *context, RequestType *request,
ServerAsyncResponseWriter<ResponseType> *response,
grpc::CompletionQueue *new_call_cq,
ServerCompletionQueue *notification_cq, void *tag)

The signature of the handler for an asynchronous RPC, that is handled by this CallData.

Parameters

  • context (ServiceType::*)(grpc::ServerContext)

  • request (RequestType)

  • response (ServerAsyncResponseWriter<ResponseType>)

  • new_call_cq (grpc::CompletionQueue)

  • notification_cq (ServerCompletionQueue)

  • tag (void)

Attributes

Public

Id

int Id = 0

The unique ID of this CallData instance.

Protected

SContext

ServerContext *SContext

The Context of the Server that this CallData is associated with.


Responder

ServerAsyncResponseWriter<ResponseType> Responder

An Object that can be used to send a response to the client.


Request

RequestType Request

The incoming request message from the client.


Response

ResponseType *Response = nullptr

The outgoing response message to the client.


TargetRPC

AsyncAPIHandler TargetRPC

A method ptr to the type of Requests this CallData will be servicing.


CallDataStatus

CallStatus CallDataStatus

The current state of the RPC.


Service

ServiceType *Service

The service that this CallData is associated with.


CQueue

ServerCompletionQueue *CQueue

The proiducer-consumer completion queue that this CallData is associated with.


bReusable

bool bReusable

Variable defining whether we discard this CallData or replace it after serving one RPC.

Source: Source/ScholaProtobuf/Public/ProtobufBackends/gRPC/CallData.h