Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions GrpcInterface/RiaGrpcCommandService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ grpc::Status RiaGrpcCommandService::Execute( grpc::ServerContext* context, const
}
else
{
assignPdmObjectValues( commandHandle, *request, grpcOneOfMessage );
auto result = assignPdmObjectValues( commandHandle, *request, grpcOneOfMessage );
if ( !result )
{
telemetryAttributes["command.status"] = "error";
telemetryAttributes["command.error"] = result.error().toStdString();
RiaOpenTelemetryManager::instance().reportEventAsync( "grpc.command_execute", telemetryAttributes );

return grpc::Status( grpc::INVALID_ARGUMENT, result.error().toStdString() );
}
telemetryAttributes["command.type"] = "standard";
}

Expand Down Expand Up @@ -260,9 +268,10 @@ void RiaGrpcCommandService::assignPdmFieldValue( caf::PdmValueField* pdmValue
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaGrpcCommandService::assignPdmObjectValues( caf::PdmObjectHandle* pdmObjectHandle,
const google::protobuf::Message& params,
const google::protobuf::FieldDescriptor* paramDescriptor )
std::expected<void, QString>
RiaGrpcCommandService::assignPdmObjectValues( caf::PdmObjectHandle* pdmObjectHandle,
const google::protobuf::Message& params,
const google::protobuf::FieldDescriptor* paramDescriptor )
{
FieldDescriptor::Type fieldDataType = paramDescriptor->type();
const Reflection* reflection = params.GetReflection();
Expand All @@ -274,8 +283,7 @@ void RiaGrpcCommandService::assignPdmObjectValues( caf::PdmObjectHandle*
const rips::PdmObject* ripsPdmObject = dynamic_cast<const rips::PdmObject*>( &subMessage );
if ( ripsPdmObject )
{
copyPdmObjectFromRipsToCaf( ripsPdmObject, pdmObjectHandle );
return;
return copyPdmObjectFromRipsToCaf( ripsPdmObject, pdmObjectHandle );
}

auto messageDescriptor = paramDescriptor->message_type();
Expand Down Expand Up @@ -306,7 +314,8 @@ void RiaGrpcCommandService::assignPdmObjectValues( caf::PdmObjectHandle*
CAF_ASSERT( childObject );
if ( childObject )
{
assignPdmObjectValues( childObject, subMessage, parameter );
auto result = assignPdmObjectValues( childObject, subMessage, parameter );
if ( !result ) return result;
}
}
else if ( pdmValueFieldHandle )
Expand All @@ -315,6 +324,8 @@ void RiaGrpcCommandService::assignPdmObjectValues( caf::PdmObjectHandle*
}
}
}

return {};
}

//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion GrpcInterface/RiaGrpcCommandService.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RiaGrpcCommandService : public rips::Commands::AsyncService, public RiaGrp
void assignPdmFieldValue( caf::PdmValueField* pdmValueField,
const google::protobuf::Message& params,
const google::protobuf::FieldDescriptor* paramDescriptor );
void assignPdmObjectValues( caf::PdmObjectHandle* pdmObject,
std::expected<void, QString> assignPdmObjectValues( caf::PdmObjectHandle* pdmObject,
const google::protobuf::Message& params,
const google::protobuf::FieldDescriptor* paramDescriptor );

Expand Down
11 changes: 10 additions & 1 deletion GrpcInterface/RiaGrpcPdmObjectService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,16 @@ grpc::Status RiaGrpcPdmObjectService::CallPdmObjectMethod( grpc::ServerContext*
caf::PdmObjectMethodFactory::instance()->createMethod( matchingObject, methodKeyword );
if ( method )
{
copyPdmObjectFromRipsToCaf( &( request->params() ), method.get() );
if ( auto result = copyPdmObjectFromRipsToCaf( &( request->params() ), method.get() ); !result )
{
telemetryAttributes["pdm.status"] = "failed";
telemetryAttributes["pdm.error"] = result.error().toStdString();
RiaOpenTelemetryManager::instance().reportEventAsync( "grpc.pdm_method_call", telemetryAttributes );

RiaLogging::error(
QString( "Method '%1' failed. Error: %2" ).arg( methodKeyword ).arg( result.error() ).toStdString() );
return grpc::Status( grpc::INVALID_ARGUMENT, result.error().toStdString() );
}

// clang-tidy-19 has a bug that did the following:
// std::expected<caf::PdmObjectHandle, QString> result = method->execute();
Expand Down