Skip to content

Commit

Permalink
Fixed gRPC Client Hang issue (#349)
Browse files Browse the repository at this point in the history
* Improved cmake tests configuration

* Added option to remove occurrence in unary call

* Added option for occurrence in unary call

* Added without occurrence option for streaming calls

* Restructured the code

* Made occurrence changes to streaming vi templates

* Updated route_guide example

* Updated route_guide example

* Fixed route_guide clients

* Updated helloworld example

* Changed activeclientcalls to unordered_map

* Removed wait from cleanUpProc

* Added feature toggle for occurrence

* Improved occurrence wrapper

* Added feature toggle docs

* Bumped vipb version to v1.2.1.1
  • Loading branch information
yash-ni authored Mar 5, 2024
1 parent 0f954d4 commit 9b486f5
Show file tree
Hide file tree
Showing 17 changed files with 281 additions and 185 deletions.
21 changes: 21 additions & 0 deletions docs/FeatureToggles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Introducing Feature Toggles

Starting from release v1.2.0.1 we have added support for feature toggles. This allows you to enable or disable certain features in the application without the need to redeploy the application.

## How to use feature toggles

Feature toggles are managed through the `feature_config.ini` file (located next to _labview_grpc_server_ library). You can find the `data` section in the file. Here is an example of how to use feature toggles:

```ini
[data]
EfficientMessageCopy = TRUE
useOccurrence = TRUE
```

In the example above, the `EfficientMessageCopy` and `useOccurrence` features are enabled by default. If you want to disable a feature, you can set the value to `FALSE`.

### More about the flags

1. `EfficientMessageCopy` - This feature is used to enable or disable the efficient message copy feature. When enabled, the client will use efficient message copy to have throughput. When disabled, the client will use the default message copy.

2. `useOccurrence` - This feature is used to enable or disable the occurrence feature. When enabled, the client will use occurrence to manage synchroniation between LabVIEW execution threads. When disabled, the client will use not use LabVIEW occurrences.
5 changes: 5 additions & 0 deletions docs/QuickStart.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ From the same project,

![Say Hello Again Client Code implementation](images/HelloAgain-Client-Code.png "Say Hello Again Client Code implementation")


### [Optional] Configure feature toggles

[Feature Toggle documentation](./FeatureToggles.md)

### Run!

Just like we did before, from the `examples/helloworld` directory:
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-10-29 00:29:27" Modified_Date="2024-01-25 00:52:00" Creator="navin" Comments="" ID="c4d5e2287c361ddc6ccdc3e3db25ff26">
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-10-29 00:29:27" Modified_Date="2024-03-05 16:36:00" Creator="navin" Comments="" ID="390f05eb0dc821f5af8780d12aac45d2">
<Library_General_Settings>
<Package_File_Name>NI_lib_gRPC_Server_and_Client_Template[2]</Package_File_Name>
<Library_Version>1.2.0.1</Library_Version>
<Library_Version>1.2.1.1</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.5</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_servicer &gt;=1.0.0.5</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_library &gt;=1.2.1.1</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_servicer &gt;=1.2.1.1</Additional_External_Dependencies>
</Package_Dependencies>
<Custom_Action_VIs>
<Pre-Build_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="2024-01-25 00:52:07" Creator="navin" Comments="" ID="144778637847fe292a857e76ddc9de7e">
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-11-19 18:41:05" Modified_Date="2024-03-05 16:36:28" Creator="navin" Comments="" ID="d07b13a0a8f3e71aedc35ffaa3ca05b4">
<Library_General_Settings>
<Package_File_Name>NI_lib_LabVIEW_gRPC_Servicer</Package_File_Name>
<Library_Version>1.2.0.1</Library_Version>
<Library_Version>1.2.1.1</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.5</Additional_External_Dependencies>
<Additional_External_Dependencies>ni_lib_labview_grpc_library &gt;=1.2.1.1</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>EF4D1AC5CAC7F902A7CF8FF5793A28D2</GUID>
<GUID>2853EF4A6A207E56900A7E4A3B89B820</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>4D9DD7F1C4F365611E7BC9C68C3D0746</GUID>
<GUID>56DEEC61A2B33CDA6209D66F1823D416</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>01211C985534A0A64931AEB80B781E5B</GUID>
<GUID>37CAC1E328AC86A39F584A6C543A8B47</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>0DAEFFEC54821C1C8A04748AE22F62E7</GUID>
<GUID>0B31FB6D6BADFFD57F13DDC174FFF2DC</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>868D92BE0C2CC5C8CEC7B97978B5B57B</GUID>
<GUID>A61CAED75DFB09FF807B585DB6A2E329</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>EB0CABE3504FCDCD16AB2CCE0426666E</GUID>
<GUID>AB736E3BFE2F16DC39CAD22AED3B9A42</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>D190312A2A9E027E772830E427BDC409</GUID>
<GUID>792C56BDAF2F7B6C8C400BA54A35FF4C</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>9D246540CD96A150DF328248B0FBB69D</GUID>
<GUID>7930AED5671BE270A8A44DD524E1FF6B</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>A9D1C08BDED898EA77A18DF0558BFF54</GUID>
<GUID>EBF3BC054A4624C356F6D016BCC226AB</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>ABBDD30E4FA250571B687C540BBEF65F</GUID>
<GUID>80EC661840B290568D6B374E3ED4929B</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>D009C94F8A0CE4085DB46DB08D81EB34</GUID>
<GUID>91B118288976929E18942FC5B9EC14ED</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>0339BCF065B73EB2CFA62B59E69A63B4</GUID>
<GUID>8B469662DF05DD5A2C74E2EB7AF68AD4</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>4989E0323BB114A6D1EB7502BBA40157</GUID>
<GUID>89F1B5F7BDA2A86F19F601292A18CD1F</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>F9328007F4D8CCC6D9AF239EE1D0C1BF</GUID>
<GUID>CF4FCC3F6AB2C9C175844260ABFCED8F</GUID>
</Functions_Palette_Data>
</Library_Palette_Definition>
</VI_Package_Builder_Settings>
Binary file not shown.
Binary file not shown.
Binary file modified labview source/gRPC lv Support/Client API/Client Unary Call.vim
Binary file not shown.
Binary file not shown.
Binary file not shown.
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="2024-01-25 00:52:12" Creator="navin" Comments="" ID="5c67fc6440cfc24f38dc220b6177efd9">
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2021-10-28 23:37:57" Modified_Date="2024-03-05 16:36:48" Creator="navin" Comments="" ID="470ca4cd68b02849def07eeeb30d9cd9">
<Library_General_Settings>
<Package_File_Name>NI_lib_LabVIEW_gRPC_Library</Package_File_Name>
<Library_Version>1.2.0.1</Library_Version>
<Library_Version>1.2.1.1</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>F627CB60D44A5C4716C7A488480A4D48</GUID>
<GUID>BEFED5DB5E2108370610EE39BBEEFB14</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>64CFAF9B687AE3AFE8B3616E673536CC</GUID>
<GUID>DB38FE0CA2B16A33371A9E33EC3FB024</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>73B249E2631224E8EA80A91855771A7A</GUID>
<GUID>A301642648F8716CD2A20F4C93FC59CB</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>C6F6FDFB6E222C0392DBF68D544AD686</GUID>
<GUID>09E45FBB1C71CA79F5165A0D0744C58A</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>A93825BB3476291241D9E34DA3CF83DA</GUID>
<GUID>FDA001872E863E8C254CF53A4876F2C6</GUID>
</Functions_Palette_Data>
</Library_Palette_Definition>
</VI_Package_Builder_Settings>
1 change: 1 addition & 0 deletions labview source/gRPC lv Support/grpc-lvsupport.lvlib
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@
<Item Name="Set LVRT Module Path.vi" Type="VI" URL="../Shared/Set LVRT Module Path.vi"/>
<Item Name="Wait On Occurence.vi" Type="VI" URL="../Shared/Wait On Occurence.vi"/>
<Item Name="TranslateGrpcError.vi" Type="VI" URL="../Shared/TranslateGrpcError.vi"/>
<Item Name="Wait On Occurrence Wrapper.vi" Type="VI" URL="../Shared/Wait On Occurrence Wrapper.vi"/>
</Item>
</Library>
4 changes: 4 additions & 0 deletions src/feature_toggles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <fstream>
#include <sstream>
#include <map>
#include <algorithm>

namespace grpc_labview {
// Function to read feature configurations from an INI file
Expand Down Expand Up @@ -35,7 +36,10 @@ namespace grpc_labview {
std::string key, value;
if (std::getline(iss, key, '=') && std::getline(iss, value)) {
// Append section name to key for uniqueness
key.erase(std::remove_if(key.begin(), key.end(), ::isspace),key.end());
value.erase(std::remove_if(value.begin(), value.end(), ::isspace),value.end());
std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key;
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
featureFlags[fullKey] = (value == "true");
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/feature_toggles.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>
#include <unordered_map>

namespace grpc_labview {
class FeatureConfig {
private:
std::map<std::string, bool> featureFlags;
std::unordered_map<std::string, bool> featureFlags;

// Constructor to initialize with default values
FeatureConfig() {
featureFlags["gRPC"] = true; // Enable gRPC by default as an example, this will never be overridden by config file
featureFlags["EfficientMessageCopy"] = true;
featureFlags["data_EfficientMessageCopy"] = true;
featureFlags["data_useOccurrence"] = true;
}

public:
Expand All @@ -27,4 +28,5 @@ namespace grpc_labview {
// Function to check if a feature is enabled
bool isFeatureEnabled(const std::string& featureName) const;
};

}
Loading

0 comments on commit 9b486f5

Please sign in to comment.