Skip to content

Commit 8d299c4

Browse files
authored
feat: add flagd provider implementation (#66)
* feat: add flagd provider implementation Signed-off-by: Todd Baert <[email protected]> * add test for reason handling Signed-off-by: Todd Baert <[email protected]> * Add more doc to readme Signed-off-by: Todd Baert <[email protected]> * Make protocol enum Signed-off-by: Todd Baert <[email protected]> * use provided scope for javasdk Signed-off-by: Todd Baert <[email protected]> * Extract defaults to vars Signed-off-by: Todd Baert <[email protected]> Signed-off-by: Todd Baert <[email protected]>
1 parent f8ad9ce commit 8d299c4

File tree

15 files changed

+900
-232
lines changed

15 files changed

+900
-232
lines changed

Diff for: .gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "providers/flagd/schemas"]
2+
path = providers/flagd/schemas
3+
url = https://github.com/open-feature/schemas.git

Diff for: README.md

+76
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,82 @@ The project includes:
1414

1515
This repo uses _Release Please_ to release packages. Release Please sets up a running PR that tracks all changes for the library components, and maintains the versions according to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/), generated when [PRs are merged](https://github.com/amannn/action-semantic-pull-request). When Release Please's running PR is merged, any changed artifacts are published.
1616

17+
## Developing
18+
19+
### Requirements
20+
21+
Though we target Java 8, Java 18 is recommended for the tooling, plugins, etc. Maven 3.8+ is recommended.
22+
23+
### Testing
24+
25+
Run `mvn verify` to test, generate javadoc, and check style. If this passes locally, the CI will generally pass.
26+
27+
### Adding a module
28+
29+
1. Create a [standard directory structure](https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) in the appropriate folder (`hooks/`, `providers/`).
30+
1. Create a new `pom.xml` in the root of your new module. It must inherit from the parent POM, which implements the javadoc, testing, publishing, and other boilerplate. Be sure to add `<!--x-release-please-version -->` on the line specifying the module version, so our release tooling can update it (see sample pom below).
31+
1. Add the new package to `release-please-config.json`.
32+
1. Add the new module to the <modules>...</modules> section in the parent `pom.xml`.
33+
34+
Sample pom.xml:
35+
```xml
36+
<?xml version="1.0" encoding="UTF-8"?>
37+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
38+
<modelVersion>4.0.0</modelVersion>
39+
<modelVersion>4.0.0</modelVersion>
40+
<parent>
41+
<groupId>dev.openfeature.contrib</groupId>
42+
<artifactId>java-sdk-contrib</artifactId>
43+
<version>0.0.0</version>
44+
<relativePath>../../pom.xml</relativePath>
45+
</parent>
46+
<groupId>dev.openfeature.contrib.${providers | hooks | etc}</groupId>
47+
<artifactId>module</artifactId>
48+
<version>0.0.1</version> <!--x-release-please-version -->
49+
50+
<name>module</name>
51+
<description>Your module description</description>
52+
<url>https://openfeature.dev</url>
53+
54+
<developers>
55+
<developer>
56+
<id>Your GitHub ID</id>
57+
<name>Your Name</name>
58+
<organization>OpenFeature</organization>
59+
<url>https://openfeature.dev/</url>
60+
</developer>
61+
</developers>
62+
63+
<dependencies>
64+
<!-- dependencies your module needs (in addition to those inherited from parent) -->
65+
</dependencies>
66+
67+
<build>
68+
<plugins>
69+
<!-- plugins your module needs (in addition to those inherited from parent) -->
70+
</plugins>
71+
</build>
72+
73+
</project>
74+
```
75+
76+
### VS Code config
77+
78+
To use vscode, install the standard [Java language support extension by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java).
79+
80+
The following vscode settings are recommended (create a workspace settings file at .vscode/settings.json):
81+
82+
```json
83+
{
84+
"java.configuration.updateBuildConfiguration": "interactive",
85+
"java.autobuild.enabled": false,
86+
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle.xml",
87+
"java.checkstyle.version": "10.3.2",
88+
"java.format.settings.url": "${workspaceFolder}/eclipse-java-google-style.xml",
89+
"java.format.enabled": false
90+
}
91+
```
92+
1793
## License
1894

1995
Apache 2.0 - See [LICENSE](./LICENSE) for more information.

Diff for: checkstyle-suppressions.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd">
4+
5+
<suppressions>
6+
<!-- don't check style of generated sources (GRPC bindings) -->
7+
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*" />
8+
</suppressions>

Diff for: checkstyle.xml

+207-190
Large diffs are not rendered by default.

Diff for: hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/OpenTelemetryHook.java

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public OpenTelemetryHook() {
1717

1818
/**
1919
* A test method...
20+
*
2021
* @return {boolean}
2122
*/
2223
public static boolean test() {

Diff for: pom.xml

+20-4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@
2626

2727
<dependencies>
2828
<dependency>
29+
<!-- provided -->
2930
<groupId>dev.openfeature</groupId>
3031
<artifactId>javasdk</artifactId>
31-
<version>0.0.3</version>
32+
<!-- 0.1.0 or greater -->
33+
<version>[0.1,)</version>
34+
<!-- use the version provided at runtime -->
35+
<scope>provided</scope>
3236
</dependency>
3337

38+
<dependency>
39+
<groupId>org.projectlombok</groupId>
40+
<artifactId>lombok</artifactId>
41+
<version>1.18.24</version>
42+
<scope>provided</scope>
43+
</dependency>
44+
<!-- end provided -->
45+
3446
<!-- test -->
3547
<dependency>
3648
<groupId>org.mockito</groupId>
@@ -86,6 +98,7 @@
8698
<version>1.8.1</version>
8799
<scope>test</scope>
88100
</dependency>
101+
<!-- end test -->
89102
</dependencies>
90103

91104
<build>
@@ -119,13 +132,13 @@
119132
<dependency>
120133
<groupId>com.puppycrawl.tools</groupId>
121134
<artifactId>checkstyle</artifactId>
122-
<version>8.31</version>
135+
<version>10.3.2</version>
123136
</dependency>
124137
</dependencies>
125138
<executions>
126139
<execution>
127140
<id>validate</id>
128-
<phase>validate</phase>
141+
<phase>verify</phase>
129142
<goals>
130143
<goal>check</goal>
131144
</goals>
@@ -136,7 +149,9 @@
136149
<plugin>
137150
<groupId>org.apache.maven.plugins</groupId>
138151
<artifactId>maven-pmd-plugin</artifactId>
139-
<version>3.13.0</version>
152+
<configuration>
153+
<excludeRoots>${basedir}/target/generated-sources/</excludeRoots>
154+
</configuration>
140155
<executions>
141156
<execution>
142157
<id>run-pmd</id>
@@ -221,6 +236,7 @@
221236
<version>3.4.0</version>
222237
<configuration>
223238
<failOnWarnings>true</failOnWarnings>
239+
<excludePackageNames>dev.openfeature.flagd.grpc</excludePackageNames>
224240
</configuration>
225241
<executions>
226242
<execution>

Diff for: providers/flagd/pom.xml

+96
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,102 @@
2626

2727
<dependencies>
2828
<!-- we inherent dev.openfeature.javasdk and the test dependencies from the parent pom -->
29+
30+
<dependency>
31+
<groupId>io.grpc</groupId>
32+
<artifactId>grpc-netty-shaded</artifactId>
33+
<version>1.48.1</version>
34+
<scope>runtime</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.grpc</groupId>
38+
<artifactId>grpc-protobuf</artifactId>
39+
<version>1.48.1</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.grpc</groupId>
43+
<artifactId>grpc-stub</artifactId>
44+
<version>1.48.1</version>
45+
</dependency>
46+
<dependency>
47+
<!-- necessary for Java 9+ -->
48+
<groupId>org.apache.tomcat</groupId>
49+
<artifactId>annotations-api</artifactId>
50+
<version>6.0.53</version>
51+
<scope>provided</scope>
52+
</dependency>
2953
</dependencies>
3054

55+
<build>
56+
<!-- required for protobuf generation -->
57+
<extensions>
58+
<extension>
59+
<groupId>kr.motd.maven</groupId>
60+
<artifactId>os-maven-plugin</artifactId>
61+
<version>1.6.2</version>
62+
</extension>
63+
</extensions>
64+
65+
<plugins>
66+
<plugin>
67+
<groupId>org.codehaus.mojo</groupId>
68+
<artifactId>exec-maven-plugin</artifactId>
69+
<version>3.1.0</version>
70+
<executions>
71+
<execution>
72+
<id>update-schemas-submodule</id>
73+
<phase>validate</phase>
74+
<goals>
75+
<goal>exec</goal>
76+
</goals>
77+
<configuration>
78+
<!-- run: git submodule update \-\-init \-\-recursive -->
79+
<executable>git</executable>
80+
<arguments>
81+
<argument>submodule</argument>
82+
<argument>update</argument>
83+
<argument>--init</argument>
84+
<argument>--recursive</argument>
85+
</arguments>
86+
</configuration>
87+
</execution>
88+
<execution>
89+
<id>copy-protobuf-definition</id>
90+
<phase>validate</phase>
91+
<goals>
92+
<goal>exec</goal>
93+
</goals>
94+
<configuration>
95+
<!-- run: cp schemas/protobuf/schema/v1/schema.proto src/main/proto/ -->
96+
<executable>cp</executable>
97+
<arguments>
98+
<argument>schemas/protobuf/schema/v1/schema.proto</argument>
99+
<argument>src/main/proto/</argument>
100+
</arguments>
101+
</configuration>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
106+
<plugin>
107+
<groupId>org.xolstice.maven.plugins</groupId>
108+
<artifactId>protobuf-maven-plugin</artifactId>
109+
<version>0.6.1</version>
110+
<configuration>
111+
<protocArtifact>com.google.protobuf:protoc:3.21.1:exe:${os.detected.classifier}</protocArtifact>
112+
<pluginId>grpc-java</pluginId>
113+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.48.1:exe:${os.detected.classifier}</pluginArtifact>
114+
</configuration>
115+
<executions>
116+
<execution>
117+
<goals>
118+
<goal>compile</goal>
119+
<goal>compile-custom</goal>
120+
</goals>
121+
</execution>
122+
</executions>
123+
</plugin>
124+
</plugins>
125+
</build>
126+
31127
</project>

Diff for: providers/flagd/schemas

Submodule schemas added at 910fa33

0 commit comments

Comments
 (0)