Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
sighphyre committed Nov 28, 2024
2 parents d83d62d + 19c1a3c commit 2ec31e5
Show file tree
Hide file tree
Showing 31 changed files with 955 additions and 391 deletions.
52 changes: 24 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@ on:
branches:
- main



jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: [8,11]
version: [8, 11, 17]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.version }}
cache: 'maven'
distribution: 'temurin'
cache: "maven"
distribution: "temurin"
- name: Build, test, coverage
run: ./mvnw clean test jacoco:report coveralls:report
run: ./mvnw clean test jacoco:report
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-empty: true
base-path: src/main/java
parallel: true
flag-name: run-jvm-${{ join(matrix.*, '-') }}
- name: Notify Slack of pipeline completion
uses: 8398a7/action-slack@v2
with:
Expand All @@ -34,28 +40,18 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook }}
if: always()
java17:
finish:
needs: build
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/checkout@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Build, test, coverage
run: ./mvnw clean test jacoco:report coveralls:report
env:
MAVEN_OPTS: "--add-opens java.base/java.net=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
- name: Notify Slack of pipeline completion
uses: 8398a7/action-slack@v2
fetch-depth: 0
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
status: ${{ job.status }}
author_name: Github Action
text: Build on Java 17
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook }}
if: always()
parallel-finished: true
carryforward: run-jvm-8,run-jvm-11,run-jvm-17

5 changes: 3 additions & 2 deletions .github/workflows/publish_javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Build
run: ./mvnw javadoc:javadoc
- name: Deploy docs to pages
Expand Down
36 changes: 28 additions & 8 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
on:
pull_request:


jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: [8,11,17]
version: [ 8, 11, 17 ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.version }}
cache: 'maven'
distribution: 'temurin'
cache: "maven"
distribution: "temurin"
- name: Build, test, coverage
env:
YGGDRASIL_LIB_PATH: .
run: ./mvnw clean test jacoco:report coveralls:report
run: ./mvnw clean test jacoco:report
- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-empty: true
flag-name: run-jvm-${{ join(matrix.*, '-') }}
parallel: true
base-path: src/main/java
finish:
needs: build
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: run-jvm-8,run-jvm-11,run-jvm-17
24 changes: 16 additions & 8 deletions .github/workflows/release_changelog.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
name: 'Releases'
name: "Releases"
on:
push:
tags:
- 'unleash-client-java-*'
- "unleash-client-java-*"

jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build changelog
id: github_release
uses: metcalfc/changelog-generator@v0.4.4
uses: metcalfc/changelog-generator@v4.2.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: actions/create-release@v1
uses: ncipollo/release-action@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.github_release.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
finish:
needs: build
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: run-jvm-8,run-jvm-11,run-jvm-17
4 changes: 2 additions & 2 deletions .github/workflows/release_to_central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout code
- name: Setup Java and Maven Central Repo
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

**Note:** Since 6.0.1 onwards, we moved the changelog into the release notes of each version. You will find hte details here https://github.com/Unleash/unleash-client-java/releases

## 6.0.1
- Make connect and read timeouts configurable for both toggle fetching and metrics posting
## 6.0.0
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ This section shows you how to get started quickly and explains some common confi

### Step 1: Install the Unleash Java SDK

You need to add the Unleash SDK as a dependency for your project. Here's how you would add it to your `pom.xml` file:
You need to add the Unleash SDK as a dependency for your project. Here's how you would add it to your `pom.xml` and `build.gradle` file:

**pom.xml**
```xml
<dependency>
<groupId>io.getunleash</groupId>
<artifactId>unleash-client-java</artifactId>
<version>Latest version here</version>
</dependency>
```

**build.gradle**
```gradle
implementation("io.getunleash:unleash-client-java:$unleashedVersion")
```

### Step 2: Create a new Unleash instance

Expand Down Expand Up @@ -467,6 +471,7 @@ The `UnleashConfig$Builder` class (created via `UnleashConfig.builder()`) expose
| `unleashContextProvider` | An [Unleash context provider used to configure Unleash](#2-via-an-unleashcontextprovider). | No | `null` |
| `unleashFeatureFetcherFactory` | A factory providing a FeatureFetcher implementation. | No | [`HttpFeatureFetcher::new`](src/main/java/io/getunleash/repository/HttpFeatureFetcher.java) |
| `unleashMetricsSenderFactory` | A factory providing a MetricSender implementation. | No | [`DefaultHttpMetricsSender::new`](src/main/java/io/getunleash/metric/DefaultHttpMetricsSender.java) |
| `startupExceptionHandler` | Handler for the behavior in the event of an error when starting the client. | No | `null` |

When you have set all the desired options, initialize the configuration with the `build` method.
You can then pass the configuration to the Unleash client constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,53 @@
import io.getunleash.util.UnleashConfig;

public class AdvancedConstraints {

public static void main(String[] args) throws InterruptedException {
UnleashConfig config = UnleashConfig.builder().appName("client-example.advanced")
.customHttpHeader("Authorization",
"*:production.ZvzGdauVXYPyevrQVqnt8LSRHKuW")
.unleashAPI("http://localhost:1500/api").instanceId("example")
UnleashConfig config = UnleashConfig.builder()
.appName("client-example.advanced.java")
.customHttpHeader(
"Authorization",
getOrElse("UNLEASH_API_TOKEN",
"default:default.a45fede67f99b17f67312c93e00f448340e7af4ace2b0de2650f5a99"))
.unleashAPI(getOrElse("UNLEASH_API_URL", "http://localhost:3063/api"))
.instanceId("java-example")
.synchronousFetchOnInitialisation(true)
.subscriber(new UnleashSubscriber() {
@Override
public void togglesFetched(FeatureToggleResponse toggleResponse) {
System.out.println(toggleResponse);
System.out.println(toggleResponse.getToggleCollection().getFeatures().size());
}
})
.sendMetricsInterval(30)
.subscriber(
new UnleashSubscriber() {
@Override
public void togglesFetched(
FeatureToggleResponse toggleResponse) {
System.out.println(toggleResponse);
System.out.println(
toggleResponse
.getToggleCollection()
.getFeatures()
.size());
}
})
.build();
Unleash unleash = new DefaultUnleash(config);
while (true) {
Thread.sleep(2000);
UnleashContext context = UnleashContext.builder().addProperty("semver", "1.5.2").build();
System.out.println(unleash.isEnabled("advanced.constraints", context)); // expect this to be true
UnleashContext smallerSemver = UnleashContext.builder().addProperty("semver", "1.1.0").build();
System.out.println(unleash.isEnabled("advanced.constraints", smallerSemver)); // expect this to be false
UnleashContext context = UnleashContext.builder()
.addProperty("semver", "1.5.2")
.build();
System.out.println(
unleash.isEnabled("advanced.constraints", context)); // expect this to be true
UnleashContext smallerSemver = UnleashContext.builder()
.addProperty("semver", "1.1.0")
.build();
System.out.println(
unleash.isEnabled("advanced.constraints", smallerSemver)); // expect this to be false
}
}

public static String getOrElse(String key, String defaultValue) {
String value = System.getenv(key);
if (value == null) {
return defaultValue;
}
return value;
}
}
7 changes: 4 additions & 3 deletions examples/spring-boot-example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
plugins {
java
id("org.springframework.boot") version "3.0.0"
id("io.spring.dependency-management") version "1.1.0"
id("org.springframework.boot") version "3.2.0"
id("io.spring.dependency-management") version "1.1.4"
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("io.getunleash:unleash-client-java:8.2.0")
implementation("io.getunleash:unleash-client-java:9.1.1")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.getunleash.unleash.example;


import io.getunleash.DefaultUnleash;
import io.getunleash.Unleash;
import io.getunleash.util.UnleashConfig;
Expand All @@ -12,9 +11,11 @@
public class UnleashSpringConfig {

@Bean
public UnleashConfig unleashConfig(@Value("${unleash.url}") String url, @Value("${unleash.apikey}") String apiKey, @Value("${unleash.appname}") String appName) {
public UnleashConfig unleashConfig(@Value("${unleash.url}") String url, @Value("${unleash.apikey}") String apiKey,
@Value("${unleash.appname}") String appName) {
UnleashConfig config = UnleashConfig.builder().unleashAPI(url).apiKey(apiKey).appName(appName)
.fetchTogglesInterval(15).build();
.synchronousFetchOnInitialisation(true)
.fetchTogglesInterval(15).build();
return config;
}

Expand Down
Loading

0 comments on commit 2ec31e5

Please sign in to comment.