Skip to content

Commit 2ea5e68

Browse files
feat(go-feature-flag)!: Introduce in-process evaluation + tracking (#1384)
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org> Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
1 parent 0eea5da commit 2ea5e68

File tree

84 files changed

+4879
-1941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4879
-1941
lines changed

providers/go-feature-flag/README.md

Lines changed: 89 additions & 72 deletions
Large diffs are not rendered by default.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env bash
2+
3+
# This script downloads the wasm file from the go-feature-flag repository and adds it to the build.
4+
5+
wasm_version="v1.45.0" # {{wasm_version}}
6+
7+
# Set the repository owner and name
8+
repo_owner="thomaspoignant"
9+
repo_name="go-feature-flag"
10+
file_suffix=".wasi"
11+
target_dir="./src/main/resources/wasm/"
12+
13+
# Function to find the download URL
14+
find_download_url() {
15+
local release_tag=$1
16+
local file_suffix=$2
17+
18+
# Get the assets for the specific release
19+
assets=$(curl -s "https://api.github.com/repos/$repo_owner/$repo_name/releases/tags/$wasm_version" | jq -r '.assets')
20+
21+
if [ -z "$assets" ]; then
22+
echo "Error: No assets found for release $wasm_version"
23+
return 1
24+
fi
25+
26+
# Find the asset that matches the file prefix
27+
download_url=$(echo "$assets" | jq -r ".[] | select(.name | endswith(\"$file_suffix\")) | .browser_download_url")
28+
29+
if [ -z "$download_url" ]; then
30+
echo "Error: No asset found with prefix '$file_suffix' in release $wasm_version"
31+
return 1
32+
fi
33+
echo "$download_url"
34+
}
35+
36+
# Function to download the file
37+
download_file() {
38+
local url=$1
39+
local target_dir=$2
40+
41+
if [ -z "$url" ]; then
42+
echo "Error: Download URL is empty."
43+
return 1
44+
fi
45+
46+
if [ -z "$target_dir" ]; then
47+
echo "Error: Target directory is empty."
48+
return 1
49+
fi
50+
51+
# Extract the filename from the URL
52+
local filename=$(basename "$url")
53+
54+
# Check if the directory exists
55+
if [ ! -d "$target_dir" ]; then
56+
mkdir -p "$target_dir" # Create the directory if it doesn't exist
57+
fi
58+
59+
# Use curl to download the file with progress
60+
echo "Downloading $filename to $target_dir..."
61+
curl -L -o "$target_dir/$filename" "$url"
62+
if [ $? -ne 0 ]; then
63+
echo "Error: Download failed."
64+
return 1
65+
fi
66+
echo "Download successful!"
67+
}
68+
69+
# Main script logic
70+
download_url=$(find_download_url "$latest_release" "$file_suffix")
71+
if [ $? -ne 0 ]; then
72+
echo "Error: Failed to find the download URL for release $latest_release."
73+
exit 1
74+
fi
75+
76+
download_file "$download_url" "$target_dir"
77+
if [ $? -ne 0 ]; then
78+
echo "Error: Failed to download the file. $download_url"
79+
exit 1
80+
fi
81+
82+
ls "$target_dir"
83+
84+
echo "Done."

providers/go-feature-flag/pom.xml

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,20 @@
3939

4040
<dependency>
4141
<groupId>com.fasterxml.jackson.core</groupId>
42-
<artifactId>jackson-databind</artifactId>
42+
<artifactId>jackson-core</artifactId>
4343
<version>2.19.0</version>
4444
</dependency>
4545

4646
<dependency>
47-
<groupId>com.squareup.okhttp3</groupId>
48-
<artifactId>okhttp</artifactId>
49-
<version>4.12.0</version>
50-
</dependency>
51-
52-
<dependency>
53-
<groupId>com.squareup.okhttp3</groupId>
54-
<artifactId>mockwebserver</artifactId>
55-
<version>4.12.0</version>
56-
<scope>test</scope>
47+
<groupId>com.fasterxml.jackson.core</groupId>
48+
<artifactId>jackson-databind</artifactId>
49+
<version>2.19.0</version>
5750
</dependency>
5851

5952
<dependency>
60-
<groupId>com.github.ben-manes.caffeine</groupId>
61-
<artifactId>caffeine</artifactId>
62-
<version>2.9.3</version>
53+
<groupId>com.fasterxml.jackson.core</groupId>
54+
<artifactId>jackson-annotations</artifactId>
55+
<version>2.19.0</version>
6356
</dependency>
6457

6558
<dependency>
@@ -82,10 +75,72 @@
8275
</dependency>
8376

8477
<dependency>
85-
<groupId>com.google.guava</groupId>
86-
<artifactId>guava</artifactId>
87-
<version>33.4.8-jre</version>
78+
<groupId>com.dylibso.chicory</groupId>
79+
<artifactId>runtime</artifactId>
80+
<version>1.2.1</version>
81+
</dependency>
82+
83+
<dependency>
84+
<groupId>com.dylibso.chicory</groupId>
85+
<artifactId>wasm</artifactId>
86+
<version>1.2.1</version>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>com.dylibso.chicory</groupId>
91+
<artifactId>wasi</artifactId>
92+
<version>1.2.1</version>
93+
</dependency>
94+
95+
<dependency>
96+
<groupId>com.squareup.okhttp3</groupId>
97+
<artifactId>mockwebserver</artifactId>
98+
<version>4.12.0</version>
99+
<scope>test</scope>
100+
</dependency>
101+
102+
<dependency>
103+
<groupId>com.squareup.okhttp3</groupId>
104+
<artifactId>okhttp</artifactId>
105+
<version>4.12.0</version>
106+
<scope>test</scope>
107+
</dependency>
108+
109+
<dependency>
110+
<groupId>com.squareup.okio</groupId>
111+
<artifactId>okio-jvm</artifactId>
112+
<version>3.12.0</version>
113+
<scope>test</scope>
88114
</dependency>
89115

116+
<dependency>
117+
<groupId>com.github.spotbugs</groupId>
118+
<artifactId>spotbugs-annotations</artifactId>
119+
<version>4.9.3</version>
120+
<scope>provided</scope>
121+
</dependency>
90122
</dependencies>
123+
<build>
124+
<plugins>
125+
<plugin>
126+
<groupId>org.codehaus.mojo</groupId>
127+
<artifactId>exec-maven-plugin</artifactId>
128+
<executions>
129+
<execution>
130+
<id>download-latest-github-asset</id>
131+
<phase>generate-resources</phase>
132+
<goals>
133+
<goal>exec</goal>
134+
</goals>
135+
<configuration>
136+
<executable>bash</executable>
137+
<arguments>
138+
<argument>${project.basedir}/download-wasm.sh</argument>
139+
</arguments>
140+
</configuration>
141+
</execution>
142+
</executions>
143+
</plugin>
144+
</plugins>
145+
</build>
91146
</project>

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/EvaluationResponse.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)