Skip to content

Commit

Permalink
Small typo fixes and js-ssr lambda block restructure (#493)
Browse files Browse the repository at this point in the history
* Small typo fixes and js-ssr lambda block restructure

* GetValue() -> GetValueAsync()

* C# code sample update

* Actualize Java OF provider versions

* Fix wrong code comment in Go OF provider's docs
  • Loading branch information
z4kn4fein authored Sep 30, 2024
1 parent df2cea2 commit 32ca9f7
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 28 deletions.
21 changes: 10 additions & 11 deletions website/docs/advanced/code-references/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export CONFIGCAT_USAGE_PATTERNS="<pattern1>,<pattern2>";
```

The regex pattern must include the `CC_KEY` placeholder that represents the actual feature flag or setting key in your code.
For example, the following pattern allows the recognition of Ruby symbols as flag key usage:
For example, the following pattern allows the recognition of Ruby symbols as flag key usages:

```bash
configcat scan <dir> --usage-patterns ":CC_KEY"
Expand All @@ -85,7 +85,6 @@ if FeatureFlags.enabled(:my_feature_key)
#...
end
```

:::

### Aliases
Expand All @@ -98,16 +97,16 @@ For example, the following `C#` constant's name (`MyAwesomeFeature`) will be rec
```csharp
public static class FeatureFlagKeys
{
public const string MyAwesomeFeature = "my_awesome_feature";
public const string MyAwesomeFeature = "my_awesome_feature";
}
```

The scanner will treat this constant's usage as an indirect reference to the flag.

```csharp
if (configCatClient.GetValue(FeatureFlagKeys.MyAwesomeFeature, false))
if (await configCatClient.GetValueAsync(FeatureFlagKeys.MyAwesomeFeature, false))
{
// the feature is on.
// the feature is on.
}
```

Expand Down Expand Up @@ -150,15 +149,15 @@ There's an option to set custom regex patterns for identifying additional aliase
configcat scan <dir> --alias-patterns "<pattern1>" "<pattern2>"
```

The CLI expects the patterns from `CONFIGCAT_ALIAS_PATTERNS` as a comma delimited list.
The CLI also accepts patterns from the `CONFIGCAT_ALIAS_PATTERNS` environment variable as a comma delimited list.

```bash
export CONFIGCAT_ALIAS_PATTERNS="<pattern1>,<pattern2>";
```

#### Match pattern format

The regex pattern must include at least one capture group that represents the actual alias. When more then one group is defined, the first one is selected.
The regex pattern must include at least one capture group that represents the actual alias. When more than one group is defined, the first one is selected.
To bind the actual flag keys to aliases, the CLI uses a `CC_KEY` placeholder to inject the known keys into the pattern.

For example, the following pattern allows to find aliases that point to Ruby symbols:
Expand Down Expand Up @@ -189,17 +188,17 @@ For example, the scanner will treat the `IsMyAwesomeFeatureEnabled` function of
```csharp
public class FeatureFlagProvider
{
public bool IsMyAwesomeFeatureEnabled(bool defaultValue = false)
public async Task<bool> IsMyAwesomeFeatureEnabled(bool defaultValue = false)
{
return configCatClient.GetValue("my_awesome_feature", defaultValue);
return await configCatClient.GetValueAsync("my_awesome_feature", defaultValue);
}
}
```

And will include it's usage in the scan report:
And will include its usage in the scan report:

```csharp
if (featureFlagProvider.IsMyAwesomeFeatureEnabled())
if (await featureFlagProvider.IsMyAwesomeFeatureEnabled())
{
// the feature is on.
}
Expand Down
3 changes: 3 additions & 0 deletions website/docs/sdk-reference/js-ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,11 @@ You can view a sample run [here](https://github.com/configcat/js-ssr-sdk/actions
## Next.js/AWS lambda recommendation
If the SDK is running in a Next.js application that is hosted on Vercel (AWS lambda) or your application is hosted directly in AWS lambdas, it is recommended to use the SDK in Lazy loading or Manual polling mode instead of the default Auto polling mode.
As AWS lamdbas try to minimize their uptime, the applications are terminated as soon as the sytem detects inactivity in the application.
The Auto polling mode is using a background thread to acquire the setting values from the ConfigCat servers periodically and the AWS lambda does not detect it as a running application and terminates it.
However, it can easily happen that there is an ongoing HTTP GET call towards our servers and this termination can cause errors.
The most possible error message in this case is `Request timed out while trying to fetch config JSON.`.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/sdk-reference/openfeature/go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ configcatClient := sdk.NewCustomClient(sdk.Config{SDKKey: "#YOUR-SDK-KEY#",
// Configure the provider.
openfeature.SetProvider(configcat.NewProvider(configcatClient))

# Create a client.
// Create a client.
client := openfeature.NewClient("app")
```

Expand Down
4 changes: 2 additions & 2 deletions website/docs/sdk-reference/openfeature/java.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import TabItem from '@theme/TabItem';

```groovy title="build.gradle"
dependencies {
implementation 'dev.openfeature.contrib.providers:configcat:0.0.4'
implementation 'dev.openfeature.contrib.providers:configcat:0.1.+'
implementation 'dev.openfeature:sdk:1.+'
}
```
Expand All @@ -30,7 +30,7 @@ dependencies {
<dependency>
<groupId>dev.openfeature.contrib.providers</groupId>
<artifactId>configcat</artifactId>
<version>0.0.4</version>
<version>[0.1,)</version>
</dependency>
<dependency>
<groupId>dev.openfeature</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export CONFIGCAT_USAGE_PATTERNS="<pattern1>,<pattern2>";
```

The regex pattern must include the `CC_KEY` placeholder that represents the actual feature flag or setting key in your code.
For example, the following pattern allows the recognition of Ruby symbols as flag key usage:
For example, the following pattern allows the recognition of Ruby symbols as flag key usages:

```bash
configcat scan <dir> --usage-patterns ":CC_KEY"
Expand All @@ -97,16 +97,16 @@ For example, the following `C#` constant's name (`MyAwesomeFeature`) will be rec
```csharp
public static class FeatureFlagKeys
{
public const string MyAwesomeFeature = "my_awesome_feature";
public const string MyAwesomeFeature = "my_awesome_feature";
}
```

The scanner will treat this constant's usage as an indirect reference to the flag.

```csharp
if (configCatClient.GetValue(FeatureFlagKeys.MyAwesomeFeature, false))
if (await configCatClient.GetValueAsync(FeatureFlagKeys.MyAwesomeFeature, false))
{
// the feature is on.
// the feature is on.
}
```

Expand Down Expand Up @@ -143,21 +143,21 @@ This behavior prevents false recognitions in expressions like `<input type="text

### Custom alias match patterns

There's an option to set custom regex patterns for identifying additional aliases. The `scan` command accepts a list of patterns via the `--alias-patterns` argument or via the `CONFIGCAT_ALIAS_PATTERNS` environment variable.
There's an option to set custom regex patterns for identifying additional aliases. The `scan` command accepts a list of patterns via the `--alias-patterns` argument.

```bash
configcat scan <dir> --alias-patterns "<pattern1>" "<pattern2>"
```

The CLI expects the patterns from `CONFIGCAT_ALIAS_PATTERNS` as a comma delimited list.
The CLI also accepts patterns from the `CONFIGCAT_ALIAS_PATTERNS` environment variable as a comma delimited list.

```bash
export CONFIGCAT_ALIAS_PATTERNS="<pattern1>,<pattern2>";
```

#### Match pattern format

The regex pattern must include at least one capture group that represents the actual alias. When more then one group is defined, the first one is selected.
The regex pattern must include at least one capture group that represents the actual alias. When more than one group is defined, the first one is selected.
To bind the actual flag keys to aliases, the CLI uses a `CC_KEY` placeholder to inject the known keys into the pattern.

For example, the following pattern allows to find aliases that point to Ruby symbols:
Expand Down Expand Up @@ -188,17 +188,17 @@ For example, the scanner will treat the `IsMyAwesomeFeatureEnabled` function of
```csharp
public class FeatureFlagProvider
{
public bool IsMyAwesomeFeatureEnabled(bool defaultValue = false)
public async Task<bool> IsMyAwesomeFeatureEnabled(bool defaultValue = false)
{
return configCatClient.GetValue("my_awesome_feature", defaultValue);
return await configCatClient.GetValueAsync("my_awesome_feature", defaultValue);
}
}
```

And will include it's usage in the scan report:
And will include its usage in the scan report:

```csharp
if (featureFlagProvider.IsMyAwesomeFeatureEnabled())
if (await featureFlagProvider.IsMyAwesomeFeatureEnabled())
{
// the feature is on.
}
Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-V1/sdk-reference/js-ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,11 @@ You can view a sample run [here](https://github.com/configcat/js-ssr-sdk/actions
## Next.js/AWS lambda recommendation

If the SDK is running in a Next.js application that is hosted on Vercel (AWS lambda) or your application is hosted directly in AWS lambdas, it is recommended to use the SDK in Lazy loading or Manual polling mode instead of the default Auto polling mode.

As AWS lamdbas try to minimize their uptime, the applications are terminated as soon as the sytem detects inactivity in the application.

The Auto polling mode is using a background thread to acquire the setting values from the ConfigCat servers periodically and the AWS lambda does not detect it as a running application and terminates it.

However, it can easily happen that there is an ongoing HTTP GET call towards our servers and this termination can cause errors.
The most possible error message in this case is `Request timed out while trying to fetch config JSON.`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ configcatClient := sdk.NewCustomClient(sdk.Config{SDKKey: "#YOUR-SDK-KEY#",
// Configure the provider.
openfeature.SetProvider(configcat.NewProvider(configcatClient))

# Create a client.
// Create a client.
client := openfeature.NewClient("app")
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import TabItem from '@theme/TabItem';

```groovy title="build.gradle"
dependencies {
implementation 'dev.openfeature.contrib.providers:configcat:0.0.4'
implementation 'dev.openfeature.contrib.providers:configcat:0.1.+'
implementation 'dev.openfeature:sdk:1.+'
}
```
Expand All @@ -30,7 +30,7 @@ dependencies {
<dependency>
<groupId>dev.openfeature.contrib.providers</groupId>
<artifactId>configcat</artifactId>
<version>0.0.4</version>
<version>[0.1,)</version>
</dependency>
<dependency>
<groupId>dev.openfeature</groupId>
Expand Down

0 comments on commit 32ca9f7

Please sign in to comment.