Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b4fe2f4
fix: rpc caching not behaving as expected (cleared too often) (#1115)
aepfli Jan 20, 2025
23c5e69
fix(deps): update dependency org.semver4j:semver4j to v5.6.0 (#1171)
renovate[bot] Jan 22, 2025
0b11534
feat(flagd): migrate file to own provider type
aepfli Jan 22, 2025
ac751e8
fix(deps): update grpc-java monorepo to v1.70.0 (#1172)
renovate[bot] Jan 22, 2025
921231a
fix: Use seconds instead of milliseconds (#1174)
kayukin Jan 23, 2025
7c34fed
fix(deps): update dependency io.getunleash:unleash-client-java to v9.…
renovate[bot] Jan 23, 2025
417c6df
fix(deps): update dependency com.google.protobuf:protobuf-java to v3.…
renovate[bot] Jan 26, 2025
d49d98f
fix(deps): update dependency commons-codec:commons-codec to v1.18.0 (…
renovate[bot] Jan 28, 2025
142560f
chore(deps): update providers/flagd/schemas digest to bb76343 (#1180)
renovate[bot] Jan 28, 2025
63bb327
chore(deps): update providers/flagd/spec digest to 5b07065 (#1179)
renovate[bot] Jan 28, 2025
fd7440a
fix(deps): update dependency io.getunleash:unleash-client-java to v9.…
renovate[bot] Jan 28, 2025
2570ced
chore(deps): update actions/setup-java digest to 3a4f6e1 (#1183)
renovate[bot] Jan 29, 2025
c96623d
chore(deps): update dependency net.bytebuddy:byte-buddy to v1.17.0 (#…
renovate[bot] Jan 30, 2025
8e5dc7e
chore(deps): update dependency net.bytebuddy:byte-buddy-agent to v1.1…
renovate[bot] Jan 30, 2025
40795a6
fix(deps): update dependency com.google.code.gson:gson to v2.12.0 (#1…
renovate[bot] Jan 30, 2025
c24ef48
fix(deps): update dependency com.google.code.gson:gson to v2.12.1 (#1…
renovate[bot] Jan 31, 2025
7e65b46
chore(deps): update dependency io.cucumber:cucumber-picocontainer to …
renovate[bot] Feb 3, 2025
6e26ccf
chore(deps): update dependency io.cucumber:cucumber-java to v7.21.0 (…
renovate[bot] Feb 3, 2025
c431cfb
chore(deps): update dependency io.cucumber:cucumber-junit-platform-en…
renovate[bot] Feb 3, 2025
16a8287
feat(go-feature-flag): Add exporterMetadata in the evaluation call (#…
thomaspoignant Feb 3, 2025
d38e013
chore(deps): update providers/flagd/spec digest to 8d6eeb3 (#1194)
renovate[bot] Feb 3, 2025
3c8ca74
test(flagd): use newest testbed launchpad (#1168)
aepfli Feb 6, 2025
0dd03b1
feat(flagd): migrate file to own provider type
aepfli Jan 22, 2025
057cf1b
Merge remote-tracking branch 'upstream/main' into feat/add_new_provid…
aepfli Feb 6, 2025
2137928
improve test and coverage
aepfli Feb 6, 2025
da76294
chore(deps): update providers/flagd/spec digest to 8d6eeb3 (#1197)
renovate[bot] Feb 7, 2025
4fdb0a9
chore(deps): update providers/flagd/schemas digest to bb76343 (#1196)
renovate[bot] Feb 7, 2025
e1f2bc3
chore(deps): update dependency providers/flagd/test-harness to v2 (#1…
renovate[bot] Feb 7, 2025
a7f96d9
Merge branch 'main' into feat/add_new_provider_type
aepfli Feb 7, 2025
97f48ae
fixup: add readme and missing option
aepfli Feb 7, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Set up JDK 8
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
with:
java-version: '8'
distribution: 'temurin'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Set up JDK 8
if: ${{ steps.release.outputs.releases_created }}
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
with:
java-version: '8'
distribution: 'temurin'
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[submodule "providers/flagd/test-harness"]
path = providers/flagd/test-harness
url = https://github.com/open-feature/test-harness.git
branch = v0.5.21
branch = v2.1.0
[submodule "providers/flagd/spec"]
path = providers/flagd/spec
url = https://github.com/open-feature/spec.git
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.16.1</version>
<version>1.17.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.16.1</version>
<version>1.17.0</version>
<scope>test</scope>
</dependency>
<!-- End mockito workaround-->
Expand Down Expand Up @@ -189,14 +189,21 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.20.1</version>
<version>7.21.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.20.1</version>
<version>7.21.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>7.21.0</version>
<scope>test</scope>
</dependency>

Expand Down
1 change: 1 addition & 0 deletions providers/flagd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
41 changes: 21 additions & 20 deletions providers/flagd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ The value is updated with every (re)connection to the sync implementation.
This can be used to enrich evaluations with such data.
If the `in-process` mode is not used, and before the provider is ready, the `getSyncMetadata` returns an empty map.

#### Offline mode
### Offline mode (File resolver)

In-process resolvers can also work in an offline mode.
To enable this mode, you should provide a valid flag configuration file with the option `offlineFlagSourcePath`.

```java
FlagdProvider flagdProvider = new FlagdProvider(
FlagdOptions.builder()
.resolverType(Config.Resolver.IN_PROCESS)
.resolverType(Config.Resolver.FILE)
.offlineFlagSourcePath("PATH")
.build());
```
Expand Down Expand Up @@ -103,24 +103,25 @@ variables.

Given below are the supported configurations:

| Option name | Environment variable name | Type & Values | Default | Compatible resolver |
| --------------------- | ------------------------------ | ------------------------ | --------- | ------------------- |
| resolver | FLAGD_RESOLVER | String - rpc, in-process | rpc | |
| host | FLAGD_HOST | String | localhost | rpc & in-process |
| port | FLAGD_PORT | int | 8013 | rpc & in-process |
| targetUri | FLAGD_TARGET_URI | string | null | rpc & in-process |
| tls | FLAGD_TLS | boolean | false | rpc & in-process |
| socketPath | FLAGD_SOCKET_PATH | String | null | rpc & in-process |
| certPath | FLAGD_SERVER_CERT_PATH | String | null | rpc & in-process |
| deadline | FLAGD_DEADLINE_MS | int | 500 | rpc & in-process |
| streamDeadlineMs | FLAGD_STREAM_DEADLINE_MS | int | 600000 | rpc & in-process |
| keepAliveTime | FLAGD_KEEP_ALIVE_TIME_MS | long | 0 | rpc & in-process |
| selector | FLAGD_SOURCE_SELECTOR | String | null | in-process |
| cache | FLAGD_CACHE | String - lru, disabled | lru | rpc |
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | rpc |
| maxEventStreamRetries | FLAGD_MAX_EVENT_STREAM_RETRIES | int | 5 | rpc |
| retryBackoffMs | FLAGD_RETRY_BACKOFF_MS | int | 1000 | rpc |
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | String | null | in-process |
| Option name | Environment variable name | Type & Values | Default | Compatible resolver |
|-----------------------|--------------------------------|--------------------------|-----------|-------------------------|
| resolver | FLAGD_RESOLVER | String - rpc, in-process | rpc | |
| host | FLAGD_HOST | String | localhost | rpc & in-process |
| port | FLAGD_PORT | int | 8013 | rpc & in-process |
| targetUri | FLAGD_TARGET_URI | string | null | rpc & in-process |
| tls | FLAGD_TLS | boolean | false | rpc & in-process |
| socketPath | FLAGD_SOCKET_PATH | String | null | rpc & in-process |
| certPath | FLAGD_SERVER_CERT_PATH | String | null | rpc & in-process |
| deadline | FLAGD_DEADLINE_MS | int | 500 | rpc & in-process & file |
| streamDeadlineMs | FLAGD_STREAM_DEADLINE_MS | int | 600000 | rpc & in-process |
| keepAliveTime | FLAGD_KEEP_ALIVE_TIME_MS | long | 0 | rpc & in-process |
| selector | FLAGD_SOURCE_SELECTOR | String | null | in-process |
| cache | FLAGD_CACHE | String - lru, disabled | lru | rpc |
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | int | 1000 | rpc |
| maxEventStreamRetries | FLAGD_MAX_EVENT_STREAM_RETRIES | int | 5 | rpc |
| retryBackoffMs | FLAGD_RETRY_BACKOFF_MS | int | 1000 | rpc |
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | String | null | file |
| offlinePollIntervalMs | FLAGD_OFFLINE_POLL_MS | int | 5000 | file |

> [!NOTE]
> Some configurations are only applicable for RPC resolver.
Expand Down
26 changes: 19 additions & 7 deletions providers/flagd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<properties>
<!-- exclusion expression for e2e tests -->
<testExclusions>**/e2e/*.java</testExclusions>
<io.grpc.version>1.69.1</io.grpc.version>
<io.grpc.version>1.70.0</io.grpc.version>
<!-- caution - updating this will break compatibility with older protobuf-java versions -->
<protobuf-java.min.version>3.25.5</protobuf-java.min.version>
<protobuf-java.min.version>3.25.6</protobuf-java.min.version>
</properties>

<name>flagd</name>
Expand Down Expand Up @@ -84,7 +84,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
<version>2.12.1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -122,13 +122,13 @@
<dependency>
<groupId>org.semver4j</groupId>
<artifactId>semver4j</artifactId>
<version>5.5.0</version>
<version>5.6.0</version>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.17.2</version>
<version>1.18.0</version>
</dependency>

<dependency>
Expand All @@ -149,7 +149,19 @@
<version>1.20.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<!-- uncomment for logoutput during test runs -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.16</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down Expand Up @@ -241,7 +253,7 @@
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.25.5:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.68.2:exe:${os.detected.classifier}</pluginArtifact>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.69.1:exe:${os.detected.classifier}</pluginArtifact>
<protoSourceRoot>${project.basedir}/schemas/protobuf/</protoSourceRoot>
</configuration>
<executions>
Expand Down
2 changes: 1 addition & 1 deletion providers/flagd/spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public final class Config {
static final int DEFAULT_STREAM_DEADLINE_MS = 10 * 60 * 1000;
static final int DEFAULT_STREAM_RETRY_GRACE_PERIOD = 5;
static final int DEFAULT_MAX_CACHE_SIZE = 1000;
static final int DEFAULT_OFFLINE_POLL_MS = 5000;
static final long DEFAULT_KEEP_ALIVE = 0;

static final String RESOLVER_ENV_VAR = "FLAGD_RESOLVER";
Expand All @@ -33,13 +34,15 @@ public final class Config {
static final String STREAM_DEADLINE_MS_ENV_VAR_NAME = "FLAGD_STREAM_DEADLINE_MS";
static final String SOURCE_SELECTOR_ENV_VAR_NAME = "FLAGD_SOURCE_SELECTOR";
static final String OFFLINE_SOURCE_PATH = "FLAGD_OFFLINE_FLAG_SOURCE_PATH";
static final String OFFLINE_POLL_MS = "FLAGD_OFFLINE_POLL_MS";
static final String KEEP_ALIVE_MS_ENV_VAR_NAME_OLD = "FLAGD_KEEP_ALIVE_TIME";
static final String KEEP_ALIVE_MS_ENV_VAR_NAME = "FLAGD_KEEP_ALIVE_TIME_MS";
static final String TARGET_URI_ENV_VAR_NAME = "FLAGD_TARGET_URI";
static final String STREAM_RETRY_GRACE_PERIOD = "FLAGD_RETRY_GRACE_PERIOD";

static final String RESOLVER_RPC = "rpc";
static final String RESOLVER_IN_PROCESS = "in-process";
static final String RESOLVER_FILE = "file";

public static final String STATIC_REASON = "STATIC";
public static final String CACHED_REASON = "CACHED";
Expand Down Expand Up @@ -87,6 +90,8 @@ static Resolver fromValueProvider(Function<String, String> provider) {
return Resolver.IN_PROCESS;
case "rpc":
return Resolver.RPC;
case "file":
return Resolver.FILE;
default:
log.warn("Unsupported resolver variable: {}", resolverVar);
return DEFAULT_RESOLVER_TYPE;
Expand Down Expand Up @@ -143,6 +148,11 @@ public String asString() {
public String asString() {
return RESOLVER_IN_PROCESS;
}
},
FILE {
public String asString() {
return RESOLVER_FILE;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.function.Function;
import lombok.Builder;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
* FlagdOptions is a builder to build flagd provider options.
Expand Down Expand Up @@ -119,8 +120,14 @@ public class FlagdOptions {
* File source of flags to be used by offline mode.
* Setting this enables the offline mode of the in-process provider.
*/
private String offlineFlagSourcePath;

/**
* File polling interval.
* Defaults to 0 (disabled).
**/
@Builder.Default
private String offlineFlagSourcePath = fallBackToEnvOrDefault(Config.OFFLINE_SOURCE_PATH, null);
private int offlinePollIntervalMs = fallBackToEnvOrDefault(Config.OFFLINE_POLL_MS, Config.DEFAULT_OFFLINE_POLL_MS);

/**
* gRPC custom target string.
Expand Down Expand Up @@ -193,7 +200,20 @@ void prebuild() {
resolverType = fromValueProvider(System::getenv);
}

if (port == 0) {
if (StringUtils.isBlank(offlineFlagSourcePath)) {
offlineFlagSourcePath = fallBackToEnvOrDefault(Config.OFFLINE_SOURCE_PATH, null);
}

if (!StringUtils.isEmpty(offlineFlagSourcePath) && resolverType == Config.Resolver.IN_PROCESS) {
resolverType = Config.Resolver.FILE;
}

// We need a file path for FILE Provider
if (StringUtils.isEmpty(offlineFlagSourcePath) && resolverType == Config.Resolver.FILE) {
throw new IllegalArgumentException("Resolver Type 'FILE' requires a offlineFlagSourcePath");
}

if (port == 0 && resolverType != Config.Resolver.FILE) {
port = Integer.parseInt(
fallBackToEnvOrDefault(Config.PORT_ENV_VAR_NAME, determineDefaultPortForResolver()));
}
Expand Down
Loading