Skip to content

Commit 953a035

Browse files
committed
feat: add flagd provider implementation
Signed-off-by: Todd Baert <[email protected]>
1 parent 19091d0 commit 953a035

File tree

15 files changed

+1205
-239
lines changed

15 files changed

+1205
-239
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

+69
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,75 @@ 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+
### Adding a module
20+
21+
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/`).
22+
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).
23+
1. Add the new package to `release-please-config.json`.
24+
1. Add the new module to the parent `pom.xml`.
25+
26+
Sample pom.xml:
27+
```xml
28+
<?xml version="1.0" encoding="UTF-8"?>
29+
<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">
30+
<modelVersion>4.0.0</modelVersion>
31+
<modelVersion>4.0.0</modelVersion>
32+
<parent>
33+
<groupId>dev.openfeature.contrib</groupId>
34+
<artifactId>java-sdk-contrib</artifactId>
35+
<version>0.0.0</version>
36+
<relativePath>../../pom.xml</relativePath>
37+
</parent>
38+
<groupId>dev.openfeature.contrib.${providers | hooks | etc}</groupId>
39+
<artifactId>module</artifactId>
40+
<version>0.0.1</version> <!--x-release-please-version -->
41+
42+
<name>module</name>
43+
<description>Your module description</description>
44+
<url>https://openfeature.dev</url>
45+
46+
<developers>
47+
<developer>
48+
<id>Your GitHub ID</id>
49+
<name>Your Name</name>
50+
<organization>OpenFeature</organization>
51+
<url>https://openfeature.dev/</url>
52+
</developer>
53+
</developers>
54+
55+
<dependencies>
56+
<!-- dependencies your module needs (in addition to those inherited from parent) -->
57+
</dependencies>
58+
59+
<build>
60+
<plugins>
61+
<!-- plugins your module needs (in addition to those inherited from parent) -->
62+
</plugins>
63+
</build>
64+
65+
</project>
66+
```
67+
68+
69+
### VS Code config
70+
71+
To use vscode, install the standard [Java language support extension by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java).
72+
73+
The following vscode settings are recommended (create a workspace settings file at .vscode/settings.json):
74+
75+
```json
76+
{
77+
"java.configuration.updateBuildConfiguration": "interactive",
78+
"java.autobuild.enabled": false,
79+
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle.xml",
80+
"java.checkstyle.version": "10.3.2",
81+
"java.format.settings.url": "${workspaceFolder}/eclipse-java-google-style.xml",
82+
"java.format.enabled": false
83+
}
84+
```
85+
1786
## License
1887

1988
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: eclipse-java-google-style.xml.bak

+337
Large diffs are not rendered by default.

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
import dev.openfeature.javasdk.NoOpProvider;
55
import dev.openfeature.javasdk.OpenFeatureAPI;
66

7-
/**
7+
/**
88
* A placeholder.
99
*/
1010
public class OpenTelemetryHook {
11-
12-
/**
11+
12+
/**
1313
* Create a new OpenTelemetryHook instance.
1414
*/
15-
public OpenTelemetryHook() {
15+
private OpenTelemetryHook() {
1616
}
1717

18-
/**
19-
* A test method...
20-
* @return {boolean}
18+
/**
19+
* A test.
20+
*
21+
* @return boolean
2122
*/
2223
public static boolean test() {
2324
OpenFeatureAPI.getInstance().setProvider(new NoOpProvider());

Diff for: pom.xml

+15-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@
2828
<dependency>
2929
<groupId>dev.openfeature</groupId>
3030
<artifactId>javasdk</artifactId>
31-
<version>0.0.3</version>
31+
<version>0.1.0</version>
32+
</dependency>
33+
34+
<!-- provided -->
35+
<dependency>
36+
<groupId>org.projectlombok</groupId>
37+
<artifactId>lombok</artifactId>
38+
<version>1.18.24</version>
39+
<scope>provided</scope>
3240
</dependency>
3341

3442
<!-- test -->
@@ -119,13 +127,13 @@
119127
<dependency>
120128
<groupId>com.puppycrawl.tools</groupId>
121129
<artifactId>checkstyle</artifactId>
122-
<version>8.31</version>
130+
<version>10.3.2</version>
123131
</dependency>
124132
</dependencies>
125133
<executions>
126134
<execution>
127135
<id>validate</id>
128-
<phase>validate</phase>
136+
<phase>verify</phase>
129137
<goals>
130138
<goal>check</goal>
131139
</goals>
@@ -136,7 +144,9 @@
136144
<plugin>
137145
<groupId>org.apache.maven.plugins</groupId>
138146
<artifactId>maven-pmd-plugin</artifactId>
139-
<version>3.13.0</version>
147+
<configuration>
148+
<excludeRoots>${basedir}/target/generated-sources/</excludeRoots>
149+
</configuration>
140150
<executions>
141151
<execution>
142152
<id>run-pmd</id>
@@ -221,6 +231,7 @@
221231
<version>3.4.0</version>
222232
<configuration>
223233
<failOnWarnings>true</failOnWarnings>
234+
<excludePackageNames>dev.openfeature.flagd.grpc</excludePackageNames>
224235
</configuration>
225236
<executions>
226237
<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)