Skip to content

Commit 34ac374

Browse files
authored
feat: flagd-provider ssl, socket, deadline, env support (#134)
Signed-off-by: Todd Baert <[email protected]> Signed-off-by: Todd Baert <[email protected]>
1 parent 9fc035c commit 34ac374

File tree

7 files changed

+476
-137
lines changed

7 files changed

+476
-137
lines changed

checkstyle.xml

+18-8
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<property name="optional" value="true"/>
3535
</module>
3636

37-
<!-- Checks for whitespace -->
37+
<!-- Checks for whitespace -->
3838
<!-- See http://checkstyle.org/config_whitespace.html -->
3939
<module name="FileTabCharacter">
4040
<property name="eachLine" value="true"/>
@@ -46,7 +46,23 @@
4646
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
4747
</module>
4848

49+
<module name="SuppressWarningsFilter" />
50+
4951
<module name="TreeWalker">
52+
<!-- needed for SuppressWarningsFilter -->
53+
<module name="SuppressWarningsHolder" />
54+
55+
<module name="SuppressWarnings">
56+
<property name="id" value="checkstyle:suppresswarnings"/>
57+
</module>
58+
59+
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
60+
<module name="SuppressionXpathFilter">
61+
<property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}"
62+
default="checkstyle-xpath-suppressions.xml" />
63+
<property name="optional" value="true"/>
64+
</module>
65+
5066
<module name="OuterTypeFilename"/>
5167
<module name="IllegalTokenText">
5268
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
@@ -223,7 +239,7 @@
223239
<property name="arrayInitIndent" value="4"/>
224240
</module>
225241
<module name="AbbreviationAsWordInName">
226-
<property name="ignoreFinal" value="false"/>
242+
<property name="ignoreFinal" value="true"/>
227243
<property name="allowedAbbreviations" value="API" />
228244
<property name="allowedAbbreviationLength" value="1"/>
229245
<property name="tokens"
@@ -312,11 +328,5 @@
312328
<module name="CommentsIndentation">
313329
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
314330
</module>
315-
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
316-
<module name="SuppressionXpathFilter">
317-
<property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}"
318-
default="checkstyle-xpath-suppressions.xml" />
319-
<property name="optional" value="true"/>
320-
</module>
321331
</module>
322332
</module>

pom.xml

+22
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,34 @@
114114
<version>${junit.jupiter.version}</version>
115115
<scope>test</scope>
116116
</dependency>
117+
117118
<dependency>
118119
<groupId>org.junit.platform</groupId>
119120
<artifactId>junit-platform-suite</artifactId>
120121
<version>1.8.1</version>
121122
<scope>test</scope>
122123
</dependency>
124+
125+
<dependency>
126+
<groupId>org.mockito</groupId>
127+
<artifactId>mockito-inline</artifactId>
128+
<version>3.12.4</version>
129+
<scope>test</scope>
130+
</dependency>
131+
132+
<dependency>
133+
<groupId>uk.org.webcompere</groupId>
134+
<artifactId>system-stubs-core</artifactId>
135+
<version>2.0.1</version>
136+
<scope>test</scope>
137+
</dependency>
138+
139+
<dependency>
140+
<groupId>uk.org.webcompere</groupId>
141+
<artifactId>system-stubs-jupiter</artifactId>
142+
<version>2.0.1</version>
143+
<scope>test</scope>
144+
</dependency>
123145
<!-- end test -->
124146
</dependencies>
125147

providers/flagd/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,33 @@ The `FlagdProvider` communicates with flagd via the gRPC protocol. Instantiate a
2323
FlagdProvider provider = new FlagdProvider(Protocol.HTTP, "localhost", 8013);
2424
OpenFeatureAPI.getInstance().setProvider(provider);
2525
```
26+
27+
Options can be defined in the constructor or as environment variables, with constructor options having the highest precedence.
28+
29+
| Option name | Environment variable name | Type | Default |
30+
| ----------- | ------------------------- | ------- | --------- |
31+
| host | FLAGD_HOST | string | localhost |
32+
| port | FLAGD_PORT | number | 8013 |
33+
| tls | FLAGD_TLS | boolean | false |
34+
| socketPath | FLAGD_SOCKET_PATH | string | - |
35+
| certPath | FLAGD_SERVER_CERT_PATH | string | - |
36+
37+
### Unix socket support
38+
39+
Unix socket communication with flag is facilitated via usage of the linux-native `epoll` library on `linux-x86_64` only (ARM support is pending relase of `netty-transport-native-epoll` v5). Unix sockets are not supported on other platforms or architectures.
40+
41+
### Reconnection
42+
43+
Reconnection is supported by the underlying GRPCBlockingStub. If connection to flagd is lost, it will reconnect automatically.
44+
45+
### Deadline (gRPC call timeout)
46+
47+
The deadline for an individual flag evaluation can be configured by calling `setDeadline(< deadline in millis >)`.
48+
If the gRPC call is not completed within this deadline, the gRPC call is terminated with the error `DEADLINE_EXCEEDED` and the evaluation will default.
49+
The default deadline is 500ms, though evaluations typically take on the order of 10ms.
50+
51+
### TLS
52+
53+
Though not required in deployments where flagd runs on the same host as the workload, TLS is available.
54+
55+
:warning: Note that there's a [vulnerability](https://security.snyk.io/vuln/SNYK-JAVA-IONETTY-1042268) in [netty](https://github.com/netty/netty), a transitive dependency of the underlying gRPC libraries used in the flagd-provider that fails to correctly validate certificates. This will be addressed in netty v5.

providers/flagd/pom.xml

+14-3
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,31 @@
2929

3030
<dependency>
3131
<groupId>io.grpc</groupId>
32-
<artifactId>grpc-netty-shaded</artifactId>
33-
<version>1.48.1</version>
34-
<scope>runtime</scope>
32+
<artifactId>grpc-netty</artifactId>
33+
<version>1.51.0</version>
3534
</dependency>
35+
36+
<dependency>
37+
<!-- we only support unix sockets on linux, via epoll native lib -->
38+
<groupId>io.netty</groupId>
39+
<artifactId>netty-transport-native-epoll</artifactId>
40+
<version>4.1.85.Final</version>
41+
<!-- TODO: with 5+ (still alpha), arm is support and we should package multiple versions -->
42+
<classifier>linux-x86_64</classifier>
43+
</dependency>
44+
3645
<dependency>
3746
<groupId>io.grpc</groupId>
3847
<artifactId>grpc-protobuf</artifactId>
3948
<version>1.48.2</version>
4049
</dependency>
50+
4151
<dependency>
4252
<groupId>io.grpc</groupId>
4353
<artifactId>grpc-stub</artifactId>
4454
<version>1.48.1</version>
4555
</dependency>
56+
4657
<dependency>
4758
<!-- necessary for Java 9+ -->
4859
<groupId>org.apache.tomcat</groupId>

0 commit comments

Comments
 (0)