Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed gRPC Client Hang issue #349

Merged
merged 18 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
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
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.
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
Loading