Skip to content

feat(go-feature-flag)!: Introduce in-process evaluation #1384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
161 changes: 89 additions & 72 deletions providers/go-feature-flag/README.md

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions providers/go-feature-flag/download-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

# This script downloads the wasm file from the go-feature-flag repository and adds it to the build.

wasm_version="v1.45.0" # {{wasm_version}}

# Set the repository owner and name
repo_owner="thomaspoignant"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely be updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?
This is used to build the repo URL where the WASM file is located.
And it is located in the repo thomaspoignant/go-feature-flag

repo_name="go-feature-flag"
file_suffix=".wasi"
target_dir="./src/main/resources/wasm/"

# Function to find the download URL
find_download_url() {
local release_tag=$1
local file_suffix=$2

# Get the assets for the specific release
assets=$(curl -s "https://api.github.com/repos/$repo_owner/$repo_name/releases/tags/$wasm_version" | jq -r '.assets')

if [ -z "$assets" ]; then
echo "Error: No assets found for release $wasm_version"
return 1
fi

# Find the asset that matches the file prefix
download_url=$(echo "$assets" | jq -r ".[] | select(.name | endswith(\"$file_suffix\")) | .browser_download_url")

if [ -z "$download_url" ]; then
echo "Error: No asset found with prefix '$file_suffix' in release $wasm_version"
return 1
fi
echo "$download_url"
}

# Function to download the file
download_file() {
local url=$1
local target_dir=$2

if [ -z "$url" ]; then
echo "Error: Download URL is empty."
return 1
fi

if [ -z "$target_dir" ]; then
echo "Error: Target directory is empty."
return 1
fi

# Extract the filename from the URL
local filename=$(basename "$url")

# Check if the directory exists
if [ ! -d "$target_dir" ]; then
mkdir -p "$target_dir" # Create the directory if it doesn't exist
fi

# Use curl to download the file with progress
echo "Downloading $filename to $target_dir..."
curl -L -o "$target_dir/$filename" "$url"
if [ $? -ne 0 ]; then
echo "Error: Download failed."
return 1
fi
echo "Download successful!"
}

# Main script logic
download_url=$(find_download_url "$latest_release" "$file_suffix")
if [ $? -ne 0 ]; then
echo "Error: Failed to find the download URL for release $latest_release."
exit 1
fi

download_file "$download_url" "$target_dir"
if [ $? -ne 0 ]; then
echo "Error: Failed to download the file. $download_url"
exit 1
fi

ls "$target_dir"

echo "Done."
46 changes: 31 additions & 15 deletions providers/go-feature-flag/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,13 @@
<version>2.19.0</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>4.12.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.9.3</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand All @@ -82,10 +70,38 @@
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.4.8-jre</version>
<groupId>com.dylibso.chicory</groupId>
<artifactId>runtime</artifactId>
<version>1.2.1</version>
</dependency>

<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>wasi</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>download-latest-github-asset</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<arguments>
<argument>${project.basedir}/download-wasm.sh</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

This file was deleted.

Loading