gRPC: enable multiple server->client streams of property data at the same time

This commit is contained in:
Gaute Lindkvist
2019-06-04 10:33:11 +02:00
parent 5379e95857
commit b6427d84c3

View File

@@ -38,6 +38,8 @@
using namespace rips; using namespace rips;
#define NUM_CONCURRENT_SERVER_STREAMS 10
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Abstract handler base class for streaming cell results to client /// Abstract handler base class for streaming cell results to client
/// ///
@@ -63,6 +65,8 @@ public:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
Status init(const PropertyRequest* request) Status init(const PropertyRequest* request)
{ {
m_request = request;
int caseId = request->case_request().id(); int caseId = request->case_request().id();
m_eclipseCase = dynamic_cast<RimEclipseCase*>(RiaGrpcServiceInterface::findCase(caseId)); m_eclipseCase = dynamic_cast<RimEclipseCase*>(RiaGrpcServiceInterface::findCase(caseId));
@@ -340,19 +344,24 @@ std::vector<RiaGrpcCallbackInterface*> RiaGrpcPropertiesService::createCallbacks
{ {
typedef RiaGrpcPropertiesService Self; typedef RiaGrpcPropertiesService Self;
return {new RiaGrpcUnaryCallback<Self, AvailablePropertiesRequest, AvailableProperties>( std::vector<RiaGrpcCallbackInterface*> callbacks;
this, &Self::GetAvailableProperties, &Self::RequestGetAvailableProperties), callbacks = {
new RiaGrpcServerStreamCallback<Self, PropertyRequest, PropertyChunk, RiaActiveCellResultsStateHandler>( new RiaGrpcUnaryCallback<Self, AvailablePropertiesRequest, AvailableProperties>(
this, &Self::GetActiveCellProperty, &Self::RequestGetActiveCellProperty, new RiaActiveCellResultsStateHandler), this, &Self::GetAvailableProperties, &Self::RequestGetAvailableProperties),
new RiaGrpcServerStreamCallback<Self, PropertyRequest, PropertyChunk, RiaGridCellResultsStateHandler>( new RiaGrpcClientStreamCallback<Self, PropertyInputChunk, Empty, RiaActiveCellResultsStateHandler>(
this, &Self::GetGridProperty, &Self::RequestGetGridProperty, new RiaGridCellResultsStateHandler), this, &Self::SetActiveCellProperty, &Self::RequestSetActiveCellProperty, new RiaActiveCellResultsStateHandler(true)),
new RiaGrpcClientStreamCallback<Self, PropertyInputChunk, Empty, RiaActiveCellResultsStateHandler>( new RiaGrpcClientStreamCallback<Self, PropertyInputChunk, Empty, RiaGridCellResultsStateHandler>(
this, &Self::SetActiveCellProperty, &Self::RequestSetActiveCellProperty, new RiaActiveCellResultsStateHandler(true)), this, &Self::SetGridProperty, &Self::RequestSetGridProperty, new RiaGridCellResultsStateHandler(true))};
new RiaGrpcClientStreamCallback<Self, PropertyInputChunk, Empty, RiaGridCellResultsStateHandler>(
this, &Self::SetGridProperty, &Self::RequestSetGridProperty, new RiaGridCellResultsStateHandler(true))
};
}
for (int i = 0; i < NUM_CONCURRENT_SERVER_STREAMS; ++i)
{
callbacks.push_back(new RiaGrpcServerStreamCallback<Self, PropertyRequest, PropertyChunk, RiaActiveCellResultsStateHandler>(
this, &Self::GetActiveCellProperty, &Self::RequestGetActiveCellProperty, new RiaActiveCellResultsStateHandler));
callbacks.push_back(new RiaGrpcServerStreamCallback<Self, PropertyRequest, PropertyChunk, RiaGridCellResultsStateHandler>(
this, &Self::GetGridProperty, &Self::RequestGetGridProperty, new RiaGridCellResultsStateHandler));
}
return callbacks;
}
static bool RiaGrpcPropertiesService_init = static bool RiaGrpcPropertiesService_init =
RiaGrpcServiceFactory::instance()->registerCreator<RiaGrpcPropertiesService>(typeid(RiaGrpcPropertiesService).hash_code()); RiaGrpcServiceFactory::instance()->registerCreator<RiaGrpcPropertiesService>(typeid(RiaGrpcPropertiesService).hash_code());