Skip to content

Commit

Permalink
Merge branch 'ni:master' into new-testing-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-ni authored Jul 24, 2023
2 parents e6fcf8f + cab2938 commit 2cb1143
Show file tree
Hide file tree
Showing 20 changed files with 520 additions and 37 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endif()
#----------------------------------------------------------------------
# Include generated *.pb.h files
#----------------------------------------------------------------------
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "./src" "./third_party/grpc")
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "./src" "./third_party/grpc" "${CMAKE_CURRENT_BINARY_DIR}/gens")

#----------------------------------------------------------------------
# LabVIEW support for grpc and protobuf
Expand All @@ -67,6 +67,8 @@ add_library(labview_grpc_server SHARED
src/any_support.cc
src/unpacked_fields.cc
src/grpc_load.cc
src/lv_proto_server_reflection_service.cc
src/lv_proto_server_reflection_plugin.cc
)
target_link_libraries(labview_grpc_server
${_REFLECTION}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
</Item>
<Item Name="Register gRPC Messages.vi" Type="VI" URL="../RPC Messages/Register gRPC Messages.vi"/>
</Item>
<Item Name="Generated Descriptors" Type="Folder">
<Item Name="Generated Descriptors.vi" Type="VI" URL="../Generated Descriptors/Generated Descriptors.vi"/>
</Item>
<Item Name="Run Service.vi" Type="VI" URL="../Run Service.vi"/>
<Item Name="Register Descriptors.vi" Type="VI" URL="../RPC Messages/Register Descriptors.vi"/>
</Library>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-10-29 00:29:27" Modified_Date="2023-05-08 09:22:33" Creator="navin" Comments="" ID="4411492ee449447276048982e468d3c1">
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-10-29 00:29:27" Modified_Date="2023-06-05 17:18:43" Creator="navin" Comments="" ID="ef6503e8d41fcbe29b752ad3030b06dc">
<Library_General_Settings>
<Package_File_Name>NI_lib_gRPC_Server_and_Client_Template[2]</Package_File_Name>
<Library_Version>1.0.0.4</Library_Version>
<Library_Version>1.0.0.5</Library_Version>
<Auto_Increment_Version>false</Auto_Increment_Version>
<Library_Source_Folder>..</Library_Source_Folder>
<Library_Output_Folder>..\..\Builds</Library_Output_Folder>
Expand All @@ -17,8 +17,8 @@
</Library_General_Settings>
<Advanced_Settings>
<Package_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_library &gt;=1.0.0.4</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_servicer &gt;=1.0.0.4</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_library &gt;=1.0.0.5</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_servicer &gt;=1.0.0.5</Additional_External_Dependencies>
</Package_Dependencies>
<Custom_Action_VIs>
<Pre-Build_VI/>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@
<Item Name="Basic Generate LV Icon Text Layer.vi" Type="VI" URL="../Top Level API/Basic Generate LV Icon Text Layer.vi"/>
<Item Name="UpdateLibraryFromTemplate.vi" Type="VI" URL="../Top Level API/UpdateLibraryFromTemplate.vi"/>
</Item>
<Item Name="Descriptors" Type="Folder">
<Item Name="Generate Descriptor VI.vi" Type="VI" URL="../Top Level API/Generate Descriptor VI.vi"/>
</Item>
</Item>
<Item Name="VI API" Type="Folder">
<Item Name="Block Diagram" Type="Folder">
Expand Down Expand Up @@ -301,6 +304,7 @@
<Item Name="Create Types.vi" Type="VI" URL="../Proto Parser API/LabVIEW API/Create Types.vi"/>
<Item Name="Create Methods.vi" Type="VI" URL="../Proto Parser API/LabVIEW API/Create Methods.vi"/>
<Item Name="Create Method Metadata.vi" Type="VI" URL="../Proto Parser API/LabVIEW API/Create Method Metadata.vi"/>
<Item Name="Serialize Proto.vi" Type="VI" URL="../Proto Parser API/LabVIEW API/Serialize Proto.vi"/>
</Item>
<Item Name="Animation API" Type="Folder">
<Item Name="Animation.vi" Type="VI" URL="../Animation API/Animation.vi"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-11-19 18:41:05" Modified_Date="2023-05-08 09:22:39" Creator="navin" Comments="" ID="95f6114dd5045fd9aa69c3c4c1036d79">
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-11-19 18:41:05" Modified_Date="2023-06-05 17:17:52" Creator="navin" Comments="" ID="a2a5f7086d2dcaa15aee13981895b2ab">
<Library_General_Settings>
<Package_File_Name>NI_lib_LabVIEW_gRPC_Servicer</Package_File_Name>
<Library_Version>1.0.0.4</Library_Version>
<Library_Version>1.0.0.5</Library_Version>
<Auto_Increment_Version>false</Auto_Increment_Version>
<Library_Source_Folder>..</Library_Source_Folder>
<Library_Output_Folder>..\..\Builds</Library_Output_Folder>
Expand All @@ -17,7 +17,7 @@
</Library_General_Settings>
<Advanced_Settings>
<Package_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_library &gt;=1.0.0.4</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_library &gt;=1.0.0.5</Additional_External_Dependencies>
</Package_Dependencies>
<Custom_Action_VIs>
<Pre-Build_VI/>
Expand Down Expand Up @@ -241,7 +241,7 @@
<Path>..\Servicer</Path>
<VI_Title/>
</Items_Data>
<GUID>D6FF58EEE627E9B66A43C94FB1086E84</GUID>
<GUID>6948FD5DCCF4E3337B3C389A9EDD5791</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -290,7 +290,7 @@
<Path>..\iService\Server API</Path>
<VI_Title/>
</Items_Data>
<GUID>250FEB3874685527AECDADFEB7C0560D</GUID>
<GUID>7E56F512EF0215D0CC86003316540286</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -353,7 +353,7 @@
<Path>..\Servicer\Run Servicer.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>4D99C6B285928309540046743B267905</GUID>
<GUID>396019B79D02E290437E7365DBAD6FF9</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>1</Parent_Palette_Index>
Expand Down Expand Up @@ -402,7 +402,7 @@
<Path>..\ServiceBase\Accessors\Read Server Stop.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>96E3A134756AC877E4954F35D8A646E8</GUID>
<GUID>004575DA1B60157CE74193DA8D7758B7</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>1</Parent_Palette_Index>
Expand Down Expand Up @@ -507,7 +507,7 @@
<Path>..\ServiceBase\Server API\Start.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>91248E53F5DA46525813CD93030D1E58</GUID>
<GUID>518FD4873DF9284B6BE7383061FD100B</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>2</Parent_Palette_Index>
Expand Down Expand Up @@ -598,7 +598,7 @@
<Path>..\Servicer\Accessors\Server State</Path>
<VI_Title/>
</Items_Data>
<GUID>1F78B6B9AE67689D09C853E475CB7D6F</GUID>
<GUID>4156E628BAE853D2E6A63D884C1A6809</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>2</Parent_Palette_Index>
Expand Down Expand Up @@ -675,7 +675,7 @@
<Path>..\Servicer\Server API\Stop Server.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>618C8CBD5255D30F466F0517905D9943</GUID>
<GUID>22C12A322527F303C6D993E02F9FC087</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>5</Parent_Palette_Index>
Expand Down Expand Up @@ -724,7 +724,7 @@
<Path>..\Servicer\Accessors\gRPC ID\Set gRPC ID.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>AFACC9D0682423FC83AC3979D2F9A6DA</GUID>
<GUID>E39D7679335C5A5EC8051D100FD1DFC3</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>5</Parent_Palette_Index>
Expand Down Expand Up @@ -773,7 +773,7 @@
<Path>..\Servicer\Accessors\Server Address\Set Server Address.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>DBEE0270FEB99EA85A3DD35093227854</GUID>
<GUID>6AE7725FFAD387DBE962B13C9727E974</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>5</Parent_Palette_Index>
Expand Down Expand Up @@ -822,7 +822,7 @@
<Path>..\Servicer\Accessors\Server Certificate File\Set Server Certificate File.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>AC0368A6A8B119EA101F56E089ECB904</GUID>
<GUID>B291BAA159B252FEDBA41804F7987AA2</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>5</Parent_Palette_Index>
Expand Down Expand Up @@ -871,7 +871,7 @@
<Path>..\Servicer\Accessors\Server Key File\Set Server Key File.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>2332ACF796BA82C5541608E6E9236504</GUID>
<GUID>19D1A06D5B794450DC562E7DD6DDAD9A</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>5</Parent_Palette_Index>
Expand Down Expand Up @@ -948,7 +948,7 @@
<Path>..\Servicer\Accessors\Server State\Set Server State.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>B7257ACDCC0FF83BBC7ED760CB36435B</GUID>
<GUID>F45D946F833C652A46C3112DF5431787</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>11</Parent_Palette_Index>
Expand Down Expand Up @@ -997,7 +997,7 @@
<Path>..\Servicer\Accessors\Server State\State Ref\Set Server State Ref.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>4D7B808F38795FA30B152738B8A10FB7</GUID>
<GUID>FBAAA646767A867B141B3CAEEFF4CD0F</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>11</Parent_Palette_Index>
Expand Down Expand Up @@ -1046,7 +1046,7 @@
<Path>..\Servicer\Accessors\Server State\State UE\Set Server State UE.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>D3BEF149682C45CE55C5C50C821FBE20</GUID>
<GUID>127D856DA0EC4F3E5A27E3ECDC0ED129</GUID>
</Functions_Palette_Data>
</Library_Palette_Definition>
</VI_Package_Builder_Settings>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-10-28 23:37:57" Modified_Date="2023-05-08 09:22:44" Creator="navin" Comments="" ID="4e512cbb7d8a5569aa5bbb43a3ea1d3f">
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-10-28 23:37:57" Modified_Date="2023-06-05 17:17:11" Creator="navin" Comments="" ID="f1736ff5d00b88712bbf2d3c9bd9847d">
<Library_General_Settings>
<Package_File_Name>NI_lib_LabVIEW_gRPC_Library</Package_File_Name>
<Library_Version>1.0.0.4</Library_Version>
<Library_Version>1.0.0.5</Library_Version>
<Auto_Increment_Version>false</Auto_Increment_Version>
<Library_Source_Folder>..</Library_Source_Folder>
<Library_Output_Folder>..\..\Builds</Library_Output_Folder>
Expand Down Expand Up @@ -252,7 +252,7 @@ https://github.com/ni/grpc-labview</Description>
<Path>..\Server API</Path>
<VI_Title/>
</Items_Data>
<GUID>A23B37FA5445FDEC90020B2297A399D1</GUID>
<GUID>C16816846C38B79D1C96AE264EDC3F47</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -371,7 +371,7 @@ https://github.com/ni/grpc-labview</Description>
<Path>..\Client API\Client Cancel Call.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>14CB4EB0565574553C2009D3914E8356</GUID>
<GUID>737659BB35E3EEAB9870F96AC565A19E</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -490,7 +490,7 @@ https://github.com/ni/grpc-labview</Description>
<Path>..\Server API\UnpackFromBuffer.vim</Path>
<VI_Title/>
</Items_Data>
<GUID>39F435242A7FFC09A959006EB335E8BD</GUID>
<GUID>1B9155BCD28A55A2458AEE932A55B72C</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>2</Parent_Palette_Index>
Expand Down Expand Up @@ -721,7 +721,7 @@ https://github.com/ni/grpc-labview</Description>
<Path>..\Server API\Message Requests\Write Call Response.vim</Path>
<VI_Title/>
</Items_Data>
<GUID>420FD305344A11F7ED4A829947C5AFD7</GUID>
<GUID>3FC7B26CBA933634BBF49EA4E48FD4B7</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>2</Parent_Palette_Index>
Expand Down Expand Up @@ -840,7 +840,7 @@ https://github.com/ni/grpc-labview</Description>
<Path>..\Server API\Server\Stop Server.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>BB5BE7159B0BAB0954739D52972079BF</GUID>
<GUID>BBF2AFF8187B144ACB302CD06E2BD460</GUID>
</Functions_Palette_Data>
</Library_Palette_Definition>
</VI_Package_Builder_Settings>
9 changes: 7 additions & 2 deletions src/grpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
#include <fstream>
#include <iostream>
#include <future>
#include <grpcpp/impl/server_initializer.h>
#include "lv_proto_server_reflection_plugin.h"

//---------------------------------------------------------------------
//---------------------------------------------------------------------
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
using grpc::Status;
using grpc::ServerInitializer;

namespace grpc_labview
{
Expand Down Expand Up @@ -186,7 +189,8 @@ namespace grpc_labview
}

grpc::EnableDefaultHealthCheckService(true);
grpc::reflection::InitProtoReflectionServerBuilderPlugin();
InitLVProtoReflectionServerBuilderPlugin();
// grpc::reflection::InitProtoReflectionServerBuilderPlugin();
ServerBuilder builder;

std::shared_ptr<grpc::ServerCredentials> creds;
Expand Down Expand Up @@ -266,5 +270,6 @@ namespace grpc_labview

_server = nullptr;
}
}
LVProtoServerReflectionPlugin::GetInstance()->DeleteInstance();
}
}
80 changes: 80 additions & 0 deletions src/lv_proto_server_reflection_plugin.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//---------------------------------------------------------------------
//---------------------------------------------------------------------
#include <lv_proto_server_reflection_plugin.h>
#include <grpcpp/impl/server_initializer.h>
#include <grpcpp/server_builder.h>
#include <lv_interop.h>
//---------------------------------------------------------------------
//---------------------------------------------------------------------
using grpc::ServerContext;
using grpc::Status;
using grpc::ServerInitializer;
using grpc::ServerBuilder;

namespace grpc_labview
{
LVProtoServerReflectionPlugin* LVProtoServerReflectionPlugin::m_instance = nullptr;

LVProtoServerReflectionPlugin::LVProtoServerReflectionPlugin() : reflection_service_(new grpc_labview::LVProtoServerReflectionService()) {
}

std::string LVProtoServerReflectionPlugin::name() {
return "LVProtoServerReflectionPlugin";
}

void LVProtoServerReflectionPlugin::InitServer(ServerInitializer* si) {
si->RegisterService(reflection_service_);
}

void LVProtoServerReflectionPlugin::Finish(ServerInitializer* si) {
reflection_service_->SetServiceList(si->GetServiceList());
}

void LVProtoServerReflectionPlugin::ChangeArguments(const ::std::string& name, void* value) {
// TODO
}

bool LVProtoServerReflectionPlugin::has_async_methods() const {
return false; // TODO
}
bool LVProtoServerReflectionPlugin::has_sync_methods() const {
return true; // TODO
}

void LVProtoServerReflectionPlugin::AddService(std::string serviceName) {
reflection_service_.get()->AddService(serviceName);
}

void LVProtoServerReflectionPlugin::AddFileDescriptorProto(const std::string& serializedProto) {
reflection_service_.get()->AddFileDescriptorProto(serializedProto);
}

LVProtoServerReflectionPlugin* LVProtoServerReflectionPlugin::GetInstance() {
if (m_instance == nullptr)
m_instance = new LVProtoServerReflectionPlugin();
return m_instance;
}

void LVProtoServerReflectionPlugin::DeleteInstance() {
m_instance = nullptr;
}

std::unique_ptr< ::grpc::ServerBuilderPlugin> CreateLVProtoReflection() {
return std::unique_ptr< ::grpc::ServerBuilderPlugin>(
LVProtoServerReflectionPlugin::GetInstance());
}

void InitLVProtoReflectionServerBuilderPlugin() {
static struct Initialize {
Initialize() {
::grpc::ServerBuilder::InternalAddPluginFactory(&CreateLVProtoReflection);
}
} initializer;
}

LIBRARY_EXPORT void DeserializeReflectionInfo(grpc_labview::LStrHandle serializedFileDescriptor)
{
std::string serializedDescriptorStr = grpc_labview::GetLVString(serializedFileDescriptor);
LVProtoServerReflectionPlugin::GetInstance()->AddFileDescriptorProto(serializedDescriptorStr);
}
}
Loading

0 comments on commit 2cb1143

Please sign in to comment.