mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-28 09:51:44 -06:00
gRPC: renames
This commit is contained in:
parent
c9d56bda9c
commit
14ff796392
@ -39,7 +39,7 @@ class RiaGrpcServiceInterface;
|
||||
// Base class for all gRPC-callbacks
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiaAbstractGrpcCallback
|
||||
class RiaGrpcCallbackInterface
|
||||
{
|
||||
public:
|
||||
enum CallState
|
||||
@ -52,16 +52,16 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
inline RiaAbstractGrpcCallback();
|
||||
inline RiaGrpcCallbackInterface();
|
||||
|
||||
virtual ~RiaAbstractGrpcCallback() {}
|
||||
virtual QString name() const = 0;
|
||||
virtual RiaAbstractGrpcCallback* createNewFromThis() const = 0;
|
||||
virtual void createRequestHandler(ServerCompletionQueue* completionQueue) = 0;
|
||||
virtual void onInitRequestStarted() {}
|
||||
virtual void onInitRequestCompleted() {}
|
||||
virtual void onProcessRequest() = 0;
|
||||
virtual void onFinishRequest() {}
|
||||
virtual ~RiaGrpcCallbackInterface() {}
|
||||
virtual QString name() const = 0;
|
||||
virtual RiaGrpcCallbackInterface* createNewFromThis() const = 0;
|
||||
virtual void createRequestHandler(ServerCompletionQueue* completionQueue) = 0;
|
||||
virtual void onInitRequestStarted() {}
|
||||
virtual void onInitRequestCompleted() {}
|
||||
virtual void onProcessRequest() = 0;
|
||||
virtual void onFinishRequest() {}
|
||||
|
||||
inline CallState callState() const;
|
||||
inline const Status& status() const;
|
||||
@ -80,10 +80,10 @@ protected:
|
||||
//
|
||||
//==================================================================================================
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
class RiaGrpcRequestCallback : public RiaAbstractGrpcCallback
|
||||
class RiaGrpcServiceCallback : public RiaGrpcCallbackInterface
|
||||
{
|
||||
public:
|
||||
RiaGrpcRequestCallback(ServiceT* service);
|
||||
RiaGrpcServiceCallback(ServiceT* service);
|
||||
|
||||
QString name() const override;
|
||||
const RequestT& request() const;
|
||||
@ -104,7 +104,7 @@ protected:
|
||||
//
|
||||
//==================================================================================================
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
class RiaGrpcCallback : public RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>
|
||||
class RiaGrpcUnaryCallback : public RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>
|
||||
{
|
||||
public:
|
||||
typedef ServerAsyncResponseWriter<ReplyT> ResponseWriterT;
|
||||
@ -113,9 +113,9 @@ public:
|
||||
void(ServiceT&, ServerContext*, RequestT*, ResponseWriterT*, CompletionQueue*, ServerCompletionQueue*, void*)>
|
||||
MethodRequestT;
|
||||
|
||||
RiaGrpcCallback(ServiceT* service, MethodImplT methodImpl, MethodRequestT methodRequest);
|
||||
RiaGrpcUnaryCallback(ServiceT* service, MethodImplT methodImpl, MethodRequestT methodRequest);
|
||||
|
||||
RiaAbstractGrpcCallback* createNewFromThis() const override;
|
||||
RiaGrpcCallbackInterface* createNewFromThis() const override;
|
||||
void createRequestHandler(ServerCompletionQueue* completionQueue) override;
|
||||
void onProcessRequest() override;
|
||||
|
||||
@ -141,7 +141,7 @@ private:
|
||||
//
|
||||
//==================================================================================================
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
class RiaGrpcStreamCallback : public RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>
|
||||
class RiaGrpcServerStreamCallback : public RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>
|
||||
{
|
||||
public:
|
||||
typedef ServerAsyncWriter<ReplyT> ResponseWriterT;
|
||||
@ -150,9 +150,9 @@ public:
|
||||
void(ServiceT&, ServerContext*, RequestT*, ResponseWriterT*, CompletionQueue*, ServerCompletionQueue*, void*)>
|
||||
MethodRequestT;
|
||||
|
||||
RiaGrpcStreamCallback(ServiceT* service, MethodImplT methodImpl, MethodRequestT methodRequest, StateHandlerT* stateHandler);
|
||||
RiaGrpcServerStreamCallback(ServiceT* service, MethodImplT methodImpl, MethodRequestT methodRequest, StateHandlerT* stateHandler);
|
||||
|
||||
RiaAbstractGrpcCallback* createNewFromThis() const override;
|
||||
RiaGrpcCallbackInterface* createNewFromThis() const override;
|
||||
void createRequestHandler(ServerCompletionQueue* completionQueue) override;
|
||||
void onInitRequestCompleted() override;
|
||||
void onProcessRequest() override;
|
||||
@ -181,7 +181,7 @@ private:
|
||||
//
|
||||
//==================================================================================================
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
class RiaGrpcClientStreamCallback : public RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>
|
||||
class RiaGrpcClientStreamCallback : public RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>
|
||||
{
|
||||
public:
|
||||
typedef ServerAsyncReader<ReplyT, RequestT> RequestReaderT;
|
||||
@ -192,7 +192,7 @@ public:
|
||||
|
||||
RiaGrpcClientStreamCallback(ServiceT* service, MethodImplT methodImpl, MethodRequestT methodRequest, StateHandlerT* stateHandler);
|
||||
|
||||
RiaAbstractGrpcCallback* createNewFromThis() const override;
|
||||
RiaGrpcCallbackInterface* createNewFromThis() const override;
|
||||
void createRequestHandler(ServerCompletionQueue* completionQueue) override;
|
||||
void onInitRequestStarted() override;
|
||||
void onInitRequestCompleted() override;
|
||||
|
@ -16,7 +16,7 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline RiaAbstractGrpcCallback::RiaAbstractGrpcCallback()
|
||||
inline RiaGrpcCallbackInterface::RiaGrpcCallbackInterface()
|
||||
: m_state(CREATE_HANDLER)
|
||||
, m_status(Status::OK)
|
||||
{
|
||||
@ -25,7 +25,7 @@ inline RiaAbstractGrpcCallback::RiaAbstractGrpcCallback()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaAbstractGrpcCallback::CallState RiaAbstractGrpcCallback::callState() const
|
||||
RiaGrpcCallbackInterface::CallState RiaGrpcCallbackInterface::callState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
@ -33,7 +33,7 @@ RiaAbstractGrpcCallback::CallState RiaAbstractGrpcCallback::callState() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const Status& RiaAbstractGrpcCallback::status() const
|
||||
const Status& RiaGrpcCallbackInterface::status() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
@ -41,7 +41,7 @@ const Status& RiaAbstractGrpcCallback::status() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
inline void RiaAbstractGrpcCallback::setNextCallState(CallState state)
|
||||
inline void RiaGrpcCallbackInterface::setNextCallState(CallState state)
|
||||
{
|
||||
m_state = state;
|
||||
}
|
||||
@ -50,7 +50,7 @@ inline void RiaAbstractGrpcCallback::setNextCallState(CallState state)
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::RiaGrpcRequestCallback(ServiceT* service)
|
||||
RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>::RiaGrpcServiceCallback(ServiceT* service)
|
||||
: m_service(service)
|
||||
{
|
||||
}
|
||||
@ -59,7 +59,7 @@ RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::RiaGrpcRequestCallback(Servi
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
QString RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::name() const
|
||||
QString RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>::name() const
|
||||
{
|
||||
QString fullName = QString("%1:%2(%3, %4)")
|
||||
.arg(typeid(ServiceT).name())
|
||||
@ -73,7 +73,7 @@ QString RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::name() const
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
const RequestT& RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::request() const
|
||||
const RequestT& RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>::request() const
|
||||
{
|
||||
return m_request;
|
||||
}
|
||||
@ -82,7 +82,7 @@ const RequestT& RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::request() co
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
ReplyT& RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::reply()
|
||||
ReplyT& RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>::reply()
|
||||
{
|
||||
return m_reply;
|
||||
}
|
||||
@ -91,10 +91,10 @@ ReplyT& RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>::reply()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
RiaGrpcCallback<ServiceT, RequestT, ReplyT>::RiaGrpcCallback(ServiceT* service,
|
||||
RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::RiaGrpcUnaryCallback(ServiceT* service,
|
||||
MethodImplT methodImpl,
|
||||
MethodRequestT methodRequest)
|
||||
: RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>(service)
|
||||
: RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>(service)
|
||||
, m_responder(&m_context)
|
||||
, m_methodImpl(methodImpl)
|
||||
, m_methodRequest(methodRequest)
|
||||
@ -105,34 +105,34 @@ RiaGrpcCallback<ServiceT, RequestT, ReplyT>::RiaGrpcCallback(ServiceT* serv
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
RiaAbstractGrpcCallback* RiaGrpcCallback<ServiceT, RequestT, ReplyT>::createNewFromThis() const
|
||||
RiaGrpcCallbackInterface* RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::createNewFromThis() const
|
||||
{
|
||||
return new RiaGrpcCallback<ServiceT, RequestT, ReplyT>(this->m_service, this->m_methodImpl, this->m_methodRequest);
|
||||
return new RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>(this->m_service, this->m_methodImpl, this->m_methodRequest);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
void RiaGrpcCallback<ServiceT, RequestT, ReplyT>::createRequestHandler(ServerCompletionQueue* completionQueue)
|
||||
void RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::createRequestHandler(ServerCompletionQueue* completionQueue)
|
||||
{
|
||||
// The Request-method is where the service gets registered to respond to a given request.
|
||||
m_methodRequest(*this->m_service, &m_context, &this->m_request, &m_responder, completionQueue, completionQueue, this);
|
||||
// Simple unary requests don't need initialisation, so proceed to process as soon as a request turns up.
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::PROCESS_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::PROCESS_REQUEST);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
void RiaGrpcCallback<ServiceT, RequestT, ReplyT>::onProcessRequest()
|
||||
void RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::onProcessRequest()
|
||||
{
|
||||
// Call request handler method
|
||||
this->m_status = m_methodImpl(*this->m_service, &m_context, &this->m_request, &this->m_reply);
|
||||
// Simply unary requests are finished as soon as you've done any processing.
|
||||
// So next time we receive a new tag on the command queue we should proceed to finish.
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::FINISH_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::FINISH_REQUEST);
|
||||
// Finish will push this callback back on the command queue (now with Finish as the call state).
|
||||
m_responder.Finish(this->m_reply, this->m_status, this);
|
||||
}
|
||||
@ -141,7 +141,7 @@ void RiaGrpcCallback<ServiceT, RequestT, ReplyT>::onProcessRequest()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT>
|
||||
QString RiaGrpcCallback<ServiceT, RequestT, ReplyT>::methodType() const
|
||||
QString RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::methodType() const
|
||||
{
|
||||
return "RegularMethod";
|
||||
}
|
||||
@ -150,11 +150,11 @@ QString RiaGrpcCallback<ServiceT, RequestT, ReplyT>::methodType() const
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::RiaGrpcStreamCallback(ServiceT* service,
|
||||
RiaGrpcServerStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::RiaGrpcServerStreamCallback(ServiceT* service,
|
||||
MethodImplT methodImpl,
|
||||
MethodRequestT methodRequest,
|
||||
StateHandlerT* stateHandler)
|
||||
: RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>(service)
|
||||
: RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>(service)
|
||||
, m_responder(&m_context)
|
||||
, m_methodImpl(methodImpl)
|
||||
, m_methodRequest(methodRequest)
|
||||
@ -166,9 +166,9 @@ RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::RiaGrpcStreamC
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
RiaAbstractGrpcCallback* RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::createNewFromThis() const
|
||||
RiaGrpcCallbackInterface* RiaGrpcServerStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::createNewFromThis() const
|
||||
{
|
||||
return new RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>(
|
||||
return new RiaGrpcServerStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>(
|
||||
this->m_service, m_methodImpl, m_methodRequest, new StateHandlerT);
|
||||
}
|
||||
|
||||
@ -176,21 +176,21 @@ RiaAbstractGrpcCallback* RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, State
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
void RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::createRequestHandler(
|
||||
void RiaGrpcServerStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::createRequestHandler(
|
||||
ServerCompletionQueue* completionQueue)
|
||||
{
|
||||
// The Request-method is where the service gets registered to respond to a given request.
|
||||
m_methodRequest(*this->m_service, &m_context, &this->m_request, &m_responder, completionQueue, completionQueue, this);
|
||||
// Server->Client Streaming requests require initialisation. However, we receive the complete request immediately.
|
||||
// So can proceed directly to completion of the init request.
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::INIT_REQUEST_COMPLETED);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::INIT_REQUEST_COMPLETED);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Perform initialisation tasks at the time of receiving a complete request
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
void RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onInitRequestCompleted()
|
||||
void RiaGrpcServerStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onInitRequestCompleted()
|
||||
{
|
||||
// Initialise streaming state handler
|
||||
this->m_status = m_stateHandler->init(&this->m_request);
|
||||
@ -198,14 +198,14 @@ void RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onInitReq
|
||||
if (!this->m_status.ok())
|
||||
{
|
||||
// We have an error. Proceed to finish and report the status
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::FINISH_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::FINISH_REQUEST);
|
||||
m_responder.Finish(this->m_status, this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Move on to processing and perform the first processing immediately since the client will
|
||||
// not request anything more.
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::PROCESS_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::PROCESS_REQUEST);
|
||||
this->onProcessRequest();
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ void RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onInitReq
|
||||
/// Process a streaming request and send one package
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
void RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onProcessRequest()
|
||||
void RiaGrpcServerStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onProcessRequest()
|
||||
{
|
||||
this->m_reply = ReplyT(); // Make sure it is reset
|
||||
|
||||
@ -228,7 +228,7 @@ void RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onProcess
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::FINISH_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::FINISH_REQUEST);
|
||||
// Out of range means we're finished but it isn't an error
|
||||
if (this->m_status.error_code() == grpc::OUT_OF_RANGE)
|
||||
{
|
||||
@ -243,7 +243,7 @@ void RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onProcess
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
QString RiaGrpcStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::methodType() const
|
||||
QString RiaGrpcServerStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::methodType() const
|
||||
{
|
||||
return "StreamingMethod";
|
||||
}
|
||||
@ -257,7 +257,7 @@ RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::RiaGrpcC
|
||||
MethodImplT methodImpl,
|
||||
MethodRequestT methodRequest,
|
||||
StateHandlerT* stateHandler)
|
||||
: RiaGrpcRequestCallback<ServiceT, RequestT, ReplyT>(service)
|
||||
: RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>(service)
|
||||
, m_reader(&m_context)
|
||||
, m_methodImpl(methodImpl)
|
||||
, m_methodRequest(methodRequest)
|
||||
@ -269,7 +269,7 @@ RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::RiaGrpcC
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
RiaAbstractGrpcCallback* RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::createNewFromThis() const
|
||||
RiaGrpcCallbackInterface* RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::createNewFromThis() const
|
||||
{
|
||||
return new RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>(
|
||||
this->m_service, m_methodImpl, m_methodRequest, new StateHandlerT);
|
||||
@ -286,7 +286,7 @@ void RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::cre
|
||||
m_methodRequest(*this->m_service, &m_context, &this->m_reader, completionQueue, completionQueue, this);
|
||||
// The client->server streaming requires initialisation and each request package is streamed asynchronously
|
||||
// So we need to start and complete the init request.
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::INIT_REQUEST_STARTED);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::INIT_REQUEST_STARTED);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -295,7 +295,7 @@ void RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::cre
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
void RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onInitRequestStarted()
|
||||
{
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::INIT_REQUEST_COMPLETED);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::INIT_REQUEST_COMPLETED);
|
||||
// The read call will start reading the request data and push this callback back onto the command queue
|
||||
// when the read call is completed.
|
||||
m_reader.Read(&this->m_request, this);
|
||||
@ -307,7 +307,7 @@ void RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onI
|
||||
template<typename ServiceT, typename RequestT, typename ReplyT, typename StateHandlerT>
|
||||
void RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onInitRequestCompleted()
|
||||
{
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::PROCESS_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::PROCESS_REQUEST);
|
||||
// Fully received the stream package so can now init
|
||||
this->m_status = m_stateHandler->init(&this->m_request);
|
||||
|
||||
@ -315,7 +315,7 @@ void RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onI
|
||||
{
|
||||
// We have an error. Proceed to finish and report the status
|
||||
m_reader.FinishWithError(this->m_status, this);
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::FINISH_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::FINISH_REQUEST);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ void RiaGrpcClientStreamCallback<ServiceT, RequestT, ReplyT, StateHandlerT>::onP
|
||||
|
||||
if (!this->m_status.ok())
|
||||
{
|
||||
this->setNextCallState(RiaAbstractGrpcCallback::FINISH_REQUEST);
|
||||
this->setNextCallState(RiaGrpcCallbackInterface::FINISH_REQUEST);
|
||||
if (this->m_status.error_code() == grpc::OUT_OF_RANGE)
|
||||
{
|
||||
m_reader.Finish(this->m_reply, grpc::Status::OK, this);
|
||||
|
@ -32,6 +32,7 @@
|
||||
using namespace rips;
|
||||
using namespace google::protobuf;
|
||||
|
||||
// Windows may define GetMessage as a Macro and this is in direct conflict with the gRPC GetMessage calls.
|
||||
#ifdef WIN32
|
||||
#ifdef GetMessage
|
||||
#undef GetMessage
|
||||
@ -96,11 +97,11 @@ grpc::Status RiaGrpcCommandService::Execute(grpc::ServerContext* context, const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RiaAbstractGrpcCallback*> RiaGrpcCommandService::createCallbacks()
|
||||
std::vector<RiaGrpcCallbackInterface*> RiaGrpcCommandService::createCallbacks()
|
||||
{
|
||||
typedef RiaGrpcCommandService Self;
|
||||
|
||||
return {new RiaGrpcCallback<Self, CommandParams, CommandReply>(this, &Self::Execute, &Self::RequestExecute)};
|
||||
return {new RiaGrpcUnaryCallback<Self, CommandParams, CommandReply>(this, &Self::Execute, &Self::RequestExecute)};
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,13 +41,13 @@ namespace protobuf
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
class RiaAbstractGrpcCallback;
|
||||
class RiaGrpcCallbackInterface;
|
||||
|
||||
class RiaGrpcCommandService : public rips::Commands::AsyncService, public RiaGrpcServiceInterface
|
||||
{
|
||||
public:
|
||||
grpc::Status Execute(grpc::ServerContext* context, const rips::CommandParams* request, rips::CommandReply* reply) override;
|
||||
std::vector<RiaAbstractGrpcCallback*> createCallbacks() override;
|
||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
|
@ -316,15 +316,15 @@ grpc::Status RiaGrpcGridInfoService::GetCellInfoForActiveCells(grpc::ServerConte
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RiaAbstractGrpcCallback*> RiaGrpcGridInfoService::createCallbacks()
|
||||
std::vector<RiaGrpcCallbackInterface*> RiaGrpcGridInfoService::createCallbacks()
|
||||
{
|
||||
typedef RiaGrpcGridInfoService Self;
|
||||
|
||||
return {new RiaGrpcCallback<Self, Case, GridCount>(this, &Self::GetGridCount, &Self::RequestGetGridCount),
|
||||
new RiaGrpcCallback<Self, Case, GridDimensions>(this, &Self::GetGridDimensions, &Self::RequestGetGridDimensions),
|
||||
new RiaGrpcCallback<Self, CellInfoRequest, CellCount>(this, &Self::GetCellCount, &Self::RequestGetCellCount),
|
||||
new RiaGrpcCallback<Self, Case, TimeStepDates>(this, &Self::GetTimeSteps, &Self::RequestGetTimeSteps),
|
||||
new RiaGrpcStreamCallback<Self, CellInfoRequest, CellInfoArray, RiaActiveCellInfoStateHandler>(
|
||||
return {new RiaGrpcUnaryCallback<Self, Case, GridCount>(this, &Self::GetGridCount, &Self::RequestGetGridCount),
|
||||
new RiaGrpcUnaryCallback<Self, Case, GridDimensions>(this, &Self::GetGridDimensions, &Self::RequestGetGridDimensions),
|
||||
new RiaGrpcUnaryCallback<Self, CellInfoRequest, CellCount>(this, &Self::GetCellCount, &Self::RequestGetCellCount),
|
||||
new RiaGrpcUnaryCallback<Self, Case, TimeStepDates>(this, &Self::GetTimeSteps, &Self::RequestGetTimeSteps),
|
||||
new RiaGrpcServerStreamCallback<Self, CellInfoRequest, CellInfoArray, RiaActiveCellInfoStateHandler>(
|
||||
this, &Self::GetCellInfoForActiveCells, &Self::RequestGetCellInfoForActiveCells, new RiaActiveCellInfoStateHandler)};
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace rips
|
||||
class Case;
|
||||
}
|
||||
|
||||
class RiaAbstractGrpcCallback;
|
||||
class RiaGrpcCallbackInterface;
|
||||
class RigCell;
|
||||
class RigActiveCellInfo;
|
||||
class RimEclipseCase;
|
||||
@ -78,5 +78,5 @@ public:
|
||||
const rips::CellInfoRequest* request,
|
||||
rips::CellInfoArray* reply,
|
||||
RiaActiveCellInfoStateHandler* stateHandler);
|
||||
std::vector<RiaAbstractGrpcCallback*> createCallbacks() override;
|
||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||
};
|
||||
|
@ -231,18 +231,18 @@ grpc::Status
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RiaAbstractGrpcCallback*> RiaGrpcProjectInfoService::createCallbacks()
|
||||
std::vector<RiaGrpcCallbackInterface*> RiaGrpcProjectInfoService::createCallbacks()
|
||||
{
|
||||
typedef RiaGrpcProjectInfoService Self;
|
||||
|
||||
return {
|
||||
new RiaGrpcCallback<Self, Empty, Case>(this, &Self::CurrentCase, &Self::RequestCurrentCase),
|
||||
new RiaGrpcCallback<Self, Empty, CaseInfo>(this, &Self::CurrentCaseInfo, &Self::RequestCurrentCaseInfo),
|
||||
new RiaGrpcCallback<Self, Case, CaseInfo>(this, &Self::CaseInfoFromCase, &Self::RequestCaseInfoFromCase),
|
||||
new RiaGrpcCallback<Self, Empty, CaseInfos>(this, &Self::SelectedCases, &Self::RequestSelectedCases),
|
||||
new RiaGrpcCallback<Self, Empty, CaseGroups>(this, &Self::AllCaseGroups, &Self::RequestAllCaseGroups),
|
||||
new RiaGrpcCallback<Self, Empty, CaseInfos>(this, &Self::AllCases, &Self::RequestAllCases),
|
||||
new RiaGrpcCallback<Self, CaseGroup, CaseInfos>(this, &Self::CasesInGroup, &Self::RequestCasesInGroup)};
|
||||
new RiaGrpcUnaryCallback<Self, Empty, Case>(this, &Self::CurrentCase, &Self::RequestCurrentCase),
|
||||
new RiaGrpcUnaryCallback<Self, Empty, CaseInfo>(this, &Self::CurrentCaseInfo, &Self::RequestCurrentCaseInfo),
|
||||
new RiaGrpcUnaryCallback<Self, Case, CaseInfo>(this, &Self::CaseInfoFromCase, &Self::RequestCaseInfoFromCase),
|
||||
new RiaGrpcUnaryCallback<Self, Empty, CaseInfos>(this, &Self::SelectedCases, &Self::RequestSelectedCases),
|
||||
new RiaGrpcUnaryCallback<Self, Empty, CaseGroups>(this, &Self::AllCaseGroups, &Self::RequestAllCaseGroups),
|
||||
new RiaGrpcUnaryCallback<Self, Empty, CaseInfos>(this, &Self::AllCases, &Self::RequestAllCases),
|
||||
new RiaGrpcUnaryCallback<Self, CaseGroup, CaseInfos>(this, &Self::CasesInGroup, &Self::RequestCasesInGroup)};
|
||||
}
|
||||
|
||||
static bool RiaGrpcProjectInfoService_init =
|
||||
|
@ -28,7 +28,7 @@ class Empty;
|
||||
class CaseInfo;
|
||||
} // namespace rips
|
||||
|
||||
class RiaAbstractGrpcCallback;
|
||||
class RiaGrpcCallbackInterface;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -47,5 +47,5 @@ public:
|
||||
grpc::Status CasesInGroup(grpc::ServerContext* context, const rips::CaseGroup* request, rips::CaseInfos* reply) override;
|
||||
|
||||
public:
|
||||
std::vector<RiaAbstractGrpcCallback*> createCallbacks() override;
|
||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||
};
|
||||
|
@ -302,15 +302,15 @@ grpc::Status RiaGrpcPropertiesService::SetGridResults(grpc::ServerContext*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RiaAbstractGrpcCallback*> RiaGrpcPropertiesService::createCallbacks()
|
||||
std::vector<RiaGrpcCallbackInterface*> RiaGrpcPropertiesService::createCallbacks()
|
||||
{
|
||||
typedef RiaGrpcPropertiesService Self;
|
||||
|
||||
return {new RiaGrpcCallback<Self, PropertiesRequest, AvailableProperties>(
|
||||
return {new RiaGrpcUnaryCallback<Self, PropertiesRequest, AvailableProperties>(
|
||||
this, &Self::GetAvailableProperties, &Self::RequestGetAvailableProperties),
|
||||
new RiaGrpcStreamCallback<Self, ResultRequest, ResultArray, RiaActiveCellResultsStateHandler>(
|
||||
new RiaGrpcServerStreamCallback<Self, ResultRequest, ResultArray, RiaActiveCellResultsStateHandler>(
|
||||
this, &Self::GetActiveCellResults, &Self::RequestGetActiveCellResults, new RiaActiveCellResultsStateHandler),
|
||||
new RiaGrpcStreamCallback<Self, ResultRequest, ResultArray, RiaGridCellResultsStateHandler>(
|
||||
new RiaGrpcServerStreamCallback<Self, ResultRequest, ResultArray, RiaGridCellResultsStateHandler>(
|
||||
this, &Self::GetGridResults, &Self::RequestGetGridResults, new RiaGridCellResultsStateHandler),
|
||||
new RiaGrpcClientStreamCallback<Self, ResultRequestChunk, Empty, RiaActiveCellResultsStateHandler>(
|
||||
this, &Self::SetActiveCellResults, &Self::RequestSetActiveCellResults, new RiaActiveCellResultsStateHandler),
|
||||
|
@ -54,5 +54,5 @@ public:
|
||||
rips::Empty* reply,
|
||||
RiaGridCellResultsStateHandler* stateHandler);
|
||||
|
||||
std::vector<RiaAbstractGrpcCallback*> createCallbacks() override;
|
||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||
};
|
||||
|
@ -34,10 +34,10 @@ grpc::Status RiaGrpcResInfoService::GetVersion(grpc::ServerContext* context, con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RiaAbstractGrpcCallback*> RiaGrpcResInfoService::createCallbacks()
|
||||
std::vector<RiaGrpcCallbackInterface*> RiaGrpcResInfoService::createCallbacks()
|
||||
{
|
||||
typedef RiaGrpcResInfoService Self;
|
||||
return { new RiaGrpcCallback<Self, rips::Empty, rips::Version>(this, &Self::GetVersion, &Self::RequestGetVersion) };
|
||||
return { new RiaGrpcUnaryCallback<Self, rips::Empty, rips::Version>(this, &Self::GetVersion, &Self::RequestGetVersion) };
|
||||
}
|
||||
|
||||
static bool RiaGrpcResInfoService_init =
|
||||
|
@ -37,13 +37,13 @@ namespace caf
|
||||
class PdmValueField;
|
||||
}
|
||||
|
||||
class RiaAbstractGrpcCallback;
|
||||
class RiaGrpcCallbackInterface;
|
||||
|
||||
class RiaGrpcResInfoService : public rips::ResInfo::AsyncService, public RiaGrpcServiceInterface
|
||||
{
|
||||
public:
|
||||
grpc::Status GetVersion(grpc::ServerContext* context, const rips::Empty* request, rips::Version* reply) override;
|
||||
std::vector<RiaAbstractGrpcCallback*> createCallbacks() override;
|
||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -63,18 +63,17 @@ public:
|
||||
void initialize();
|
||||
void processAllQueuedRequests();
|
||||
void quit();
|
||||
int currentPortNumber;
|
||||
|
||||
private:
|
||||
void waitForNextRequest();
|
||||
void process(RiaAbstractGrpcCallback* method);
|
||||
void process(RiaGrpcCallbackInterface* method);
|
||||
|
||||
private:
|
||||
int m_portNumber;
|
||||
std::unique_ptr<grpc::ServerCompletionQueue> m_completionQueue;
|
||||
std::unique_ptr<grpc::Server> m_server;
|
||||
std::list<std::shared_ptr<RiaGrpcServiceInterface>> m_services;
|
||||
std::list<RiaAbstractGrpcCallback*> m_unprocessedRequests;
|
||||
std::list<RiaGrpcCallbackInterface*> m_unprocessedRequests;
|
||||
std::mutex m_requestMutex;
|
||||
std::thread m_thread;
|
||||
};
|
||||
@ -171,12 +170,17 @@ void RiaGrpcServerImpl::initialize()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGrpcServerImpl::processAllQueuedRequests()
|
||||
{
|
||||
std::lock_guard<std::mutex> requestLock(m_requestMutex);
|
||||
|
||||
while (!m_unprocessedRequests.empty())
|
||||
std::list<RiaGrpcCallbackInterface*> waitingRequests;
|
||||
{
|
||||
RiaAbstractGrpcCallback* method = m_unprocessedRequests.front();
|
||||
m_unprocessedRequests.pop_front();
|
||||
// Block only while transferring the unprocessed requests to a local function list
|
||||
std::lock_guard<std::mutex> requestLock(m_requestMutex);
|
||||
waitingRequests.swap(m_unprocessedRequests);
|
||||
}
|
||||
// Now free to receive new requests from client while processing the current ones.
|
||||
while (!waitingRequests.empty())
|
||||
{
|
||||
RiaGrpcCallbackInterface* method = waitingRequests.front();
|
||||
waitingRequests.pop_front();
|
||||
process(method);
|
||||
}
|
||||
}
|
||||
@ -193,7 +197,7 @@ void RiaGrpcServerImpl::quit()
|
||||
// Clear unhandled requests
|
||||
while (!m_unprocessedRequests.empty())
|
||||
{
|
||||
RiaAbstractGrpcCallback* method = m_unprocessedRequests.front();
|
||||
RiaGrpcCallbackInterface* method = m_unprocessedRequests.front();
|
||||
m_unprocessedRequests.pop_front();
|
||||
delete method;
|
||||
}
|
||||
@ -225,7 +229,7 @@ void RiaGrpcServerImpl::waitForNextRequest()
|
||||
|
||||
while (m_completionQueue->Next(&tag, &ok))
|
||||
{
|
||||
RiaAbstractGrpcCallback* method = static_cast<RiaAbstractGrpcCallback*>(tag);
|
||||
RiaGrpcCallbackInterface* method = static_cast<RiaGrpcCallbackInterface*>(tag);
|
||||
if (ok)
|
||||
{
|
||||
std::lock_guard<std::mutex> requestLock(m_requestMutex);
|
||||
@ -239,24 +243,24 @@ void RiaGrpcServerImpl::waitForNextRequest()
|
||||
/// The gRPC calls triggered in the callback will see each callback pushed back onto the command queue.
|
||||
/// The call state will then determine what the callback should do next.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGrpcServerImpl::process(RiaAbstractGrpcCallback* method)
|
||||
void RiaGrpcServerImpl::process(RiaGrpcCallbackInterface* method)
|
||||
{
|
||||
if (method->callState() == RiaAbstractGrpcCallback::CREATE_HANDLER)
|
||||
if (method->callState() == RiaGrpcCallbackInterface::CREATE_HANDLER)
|
||||
{
|
||||
RiaLogging::debug(QString("Creating request handler for: %1").arg(method->name()));
|
||||
method->createRequestHandler(m_completionQueue.get());
|
||||
}
|
||||
else if (method->callState() == RiaAbstractGrpcCallback::INIT_REQUEST_STARTED)
|
||||
else if (method->callState() == RiaGrpcCallbackInterface::INIT_REQUEST_STARTED)
|
||||
{
|
||||
method->onInitRequestStarted();
|
||||
|
||||
}
|
||||
else if (method->callState() == RiaAbstractGrpcCallback::INIT_REQUEST_COMPLETED)
|
||||
else if (method->callState() == RiaGrpcCallbackInterface::INIT_REQUEST_COMPLETED)
|
||||
{
|
||||
RiaLogging::info(QString("Initialising handling: %1").arg(method->name()));
|
||||
method->onInitRequestCompleted();
|
||||
}
|
||||
else if (method->callState() == RiaAbstractGrpcCallback::PROCESS_REQUEST)
|
||||
else if (method->callState() == RiaGrpcCallbackInterface::PROCESS_REQUEST)
|
||||
{
|
||||
method->onProcessRequest();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RiaAbstractGrpcCallback;
|
||||
class RiaGrpcCallbackInterface;
|
||||
class RimCase;
|
||||
|
||||
//==================================================================================================
|
||||
@ -32,7 +32,7 @@ class RimCase;
|
||||
class RiaGrpcServiceInterface
|
||||
{
|
||||
public:
|
||||
virtual std::vector<RiaAbstractGrpcCallback*> createCallbacks() = 0;
|
||||
virtual std::vector<RiaGrpcCallbackInterface*> createCallbacks() = 0;
|
||||
virtual ~RiaGrpcServiceInterface() = default;
|
||||
static RimCase* findCase(int caseId);
|
||||
static size_t numberOfMessagesForByteCount(size_t messageSize, size_t byteCount = 64 * 1024u);
|
||||
|
Loading…
Reference in New Issue
Block a user