Skip to content

Commit c65d8b4

Browse files
authored
feat: v3 alignments (#5)
1 parent 3b6f4cf commit c65d8b4

51 files changed

Lines changed: 1662 additions & 996 deletions

Some content is hidden

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

.github/workflows/checks.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,55 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
checks:
17+
java:
18+
name: Java ${{ matrix.java }}
1819
runs-on: ubuntu-latest
1920
timeout-minutes: 15
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- java: "11"
26+
goal: "-Dmaven.test.skip=true clean package"
27+
- java: "25"
28+
goal: "clean verify"
2029

2130
steps:
2231
- name: Check out repository
23-
uses: actions/checkout@v6
32+
uses: actions/checkout@v7
2433

2534
- name: Set up Java
2635
uses: actions/setup-java@v5
2736
with:
28-
java-version: "24"
37+
java-version: ${{ matrix.java }}
2938
distribution: temurin
3039
cache: maven
3140

3241
- name: Build and test Maven reactor
33-
run: mvn --batch-mode clean verify
42+
run: mvn --batch-mode ${{ matrix.goal }}
3443

3544
- name: Verify published artifact boundaries
3645
run: bash scripts/verify-artifacts.sh
3746

47+
example:
48+
name: Featurevisor example-1
49+
runs-on: ubuntu-latest
50+
timeout-minutes: 15
51+
52+
steps:
53+
- name: Check out repository
54+
uses: actions/checkout@v7
55+
56+
- name: Set up Java
57+
uses: actions/setup-java@v5
58+
with:
59+
java-version: "25"
60+
distribution: temurin
61+
cache: maven
62+
63+
- name: Build SDK
64+
run: mvn --batch-mode clean install
65+
3866
- name: Set up Node.js
3967
uses: actions/setup-node@v7
4068
with:

.github/workflows/publish.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020

2121
steps:
2222
- name: Check out repository
23-
uses: actions/checkout@v6
23+
uses: actions/checkout@v7
2424

2525
- name: Set up Java and Maven publishing
2626
uses: actions/setup-java@v5
2727
with:
28-
java-version: "24"
28+
java-version: "25"
2929
distribution: temurin
3030
cache: maven
3131
server-id: github
@@ -36,14 +36,40 @@ jobs:
3636
id: version
3737
shell: bash
3838
run: |
39+
if [[ ! "$GITHUB_REF_NAME" =~ ^v3\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
40+
echo "Expected a Featurevisor Java v3 semantic version tag" >&2
41+
exit 1
42+
fi
3943
version="${GITHUB_REF_NAME#v}"
44+
if ! grep -Fq "<revision>$version</revision>" pom.xml; then
45+
echo "Tag $GITHUB_REF_NAME does not match the Maven revision" >&2
46+
exit 1
47+
fi
48+
if ! grep -Fq "<version>$version</version>" README.md; then
49+
echo "README installation version does not match $GITHUB_REF_NAME" >&2
50+
exit 1
51+
fi
52+
if ! grep -Fq "version = \"$version\"" featurevisor-sdk/src/main/java/com/featurevisor/cli/CLI.java; then
53+
echo "CLI version does not match $GITHUB_REF_NAME" >&2
54+
exit 1
55+
fi
4056
echo "version=$version" >> "$GITHUB_OUTPUT"
4157
echo "Publishing Featurevisor Java $version"
4258
43-
- name: Build, test, and publish all artifacts
59+
- name: Build and test all artifacts
60+
run: >-
61+
mvn --batch-mode
62+
-Drevision=${{ steps.version.outputs.version }}
63+
clean verify
64+
65+
- name: Verify published artifact boundaries
66+
run: bash scripts/verify-artifacts.sh
67+
68+
- name: Publish all artifacts
4469
env:
4570
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4671
run: >-
4772
mvn --batch-mode
4873
-Drevision=${{ steps.version.outputs.version }}
49-
clean deploy
74+
-DskipTests
75+
deploy

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Add the Featurevisor Java SDK as a dependency with your desired version:
8686
<dependency>
8787
<groupId>com.featurevisor</groupId>
8888
<artifactId>featurevisor-java</artifactId>
89-
<version>0.1.0</version>
89+
<version>3.0.0</version>
9090
</dependency>
9191
</dependencies>
9292
```
@@ -133,6 +133,8 @@ Featurevisor f = Featurevisor.createFeaturevisor(
133133

134134
Most applications only need `Featurevisor.createFeaturevisor`, the `Featurevisor` instance type, and `Featurevisor.FeaturevisorOptions`. Public extension and observability types include `FeaturevisorModule`, `FeaturevisorDiagnostic`, and the datafile model types.
135135

136+
Concurrent evaluations are safe after an instance is configured. Do not call state-changing methods such as `setDatafile`, `setContext`, `setSticky`, `addModule`, `removeModule`, or `close` concurrently with evaluations or with each other. Apply those changes from a serialized update path. Module, event, and diagnostic callbacks must synchronize mutable state that they capture.
137+
136138
## Initialization
137139

138140
The SDK can be initialized by passing [datafile](https://featurevisor.com/docs/building-datafiles/) content directly:
@@ -572,7 +574,7 @@ You can listen to these events that can occur at various stages in your applicat
572574
### `datafile_set`
573575

574576
```java
575-
Runnable unsubscribe = f.on("datafile_set", (event) -> {
577+
FeaturevisorUnsubscribe unsubscribe = f.on(FeaturevisorEventName.DATAFILE_SET, (event) -> {
576578
String revision = (String) event.get("revision"); // new revision
577579
String previousRevision = (String) event.get("previousRevision");
578580
Boolean revisionChanged = (Boolean) event.get("revisionChanged"); // true if revision has changed
@@ -586,7 +588,7 @@ Runnable unsubscribe = f.on("datafile_set", (event) -> {
586588
});
587589

588590
// stop listening to the event
589-
unsubscribe.run();
591+
unsubscribe.unsubscribe();
590592
```
591593

592594
The `features` array will contain keys of features that have either been:
@@ -600,7 +602,7 @@ compared to the previous datafile content that existed in the SDK instance.
600602
### `context_set`
601603

602604
```java
603-
Runnable unsubscribe = f.on("context_set", (event) -> {
605+
FeaturevisorUnsubscribe unsubscribe = f.on(FeaturevisorEventName.CONTEXT_SET, (event) -> {
604606
Boolean replaced = (Boolean) event.get("replaced"); // true if context was replaced
605607
@SuppressWarnings("unchecked")
606608
Map<String, Object> context = (Map<String, Object>) event.get("context"); // the new context
@@ -612,7 +614,7 @@ Runnable unsubscribe = f.on("context_set", (event) -> {
612614
### `sticky_set`
613615

614616
```java
615-
Runnable unsubscribe = f.on("sticky_set", (event) -> {
617+
FeaturevisorUnsubscribe unsubscribe = f.on(FeaturevisorEventName.STICKY_SET, (event) -> {
616618
Boolean replaced = (Boolean) event.get("replaced"); // true if sticky features got replaced
617619
@SuppressWarnings("unchecked")
618620
List<String> features = (List<String>) event.get("features"); // list of all affected feature keys
@@ -624,7 +626,7 @@ Runnable unsubscribe = f.on("sticky_set", (event) -> {
624626
### `error`
625627

626628
```java
627-
Emitter.UnsubscribeFunction unsubscribe = f.on(Emitter.EventName.ERROR, (event) -> {
629+
FeaturevisorUnsubscribe unsubscribe = f.on(FeaturevisorEventName.ERROR, (event) -> {
628630
FeaturevisorDiagnostic diagnostic = (FeaturevisorDiagnostic) event.get("diagnostic");
629631
System.err.println(diagnostic.getMessage());
630632
});
@@ -638,16 +640,16 @@ Besides logging with debug level enabled, you can also get more details about ho
638640

639641
```java
640642
// flag
641-
Map<String, Object> evaluation = f.evaluateFlag(featureKey, context);
643+
Evaluation evaluation = f.evaluateFlag(featureKey, context);
642644

643645
// variation
644-
Map<String, Object> evaluation = f.evaluateVariation(featureKey, context);
646+
Evaluation evaluation = f.evaluateVariation(featureKey, context);
645647

646648
// variable
647-
Map<String, Object> evaluation = f.evaluateVariable(featureKey, variableKey, context);
649+
Evaluation evaluation = f.evaluateVariable(featureKey, variableKey, context);
648650
```
649651

650-
The returned object will always contain the following properties:
652+
The returned `Evaluation` exposes the following properties:
651653

652654
- `featureKey`: the feature key
653655
- `reason`: the reason how the value was evaluated
@@ -749,6 +751,8 @@ FeaturevisorModule module = new FeaturevisorModule("diagnostic-module")
749751

750752
## Child instance
751753

754+
A child snapshots the parent keys that exist when it is spawned. Child values win for those keys. Parent keys introduced later are still inherited. Calling `close()` removes both child-owned listeners and subscriptions delegated to the parent.
755+
752756
When dealing with purely client-side applications, it is understandable that there is only one user involved, like in browser or mobile applications.
753757

754758
But when using Featurevisor SDK in server-side applications, where a single server instance can handle multiple user requests simultaneously, it is important to isolate the context for each request.
@@ -774,8 +778,11 @@ Similar to parent SDK, child instances also support several additional methods:
774778

775779
- `setContext`
776780
- `setSticky`
781+
- `evaluateFlag`
777782
- `isEnabled`
783+
- `evaluateVariation`
778784
- `getVariation`
785+
- `evaluateVariable`
779786
- `getVariable`
780787
- `getVariableBoolean`
781788
- `getVariableString`
@@ -916,9 +923,10 @@ $ make verify-artifacts
916923

917924
### Releasing
918925

919-
- Manually create a new release on [GitHub](https://github.com/featurevisor/featurevisor-java/releases)
920-
- Tag it with a prefix of `v`, like `v1.0.0`
921-
- GitHub Actions publishes the parent POM, Java SDK, and OpenFeature provider to [GitHub Packages](https://github.com/orgs/featurevisor/packages?repo_name=featurevisor-java)
926+
1. Merge the release changes into `main`.
927+
2. Tag the release with a `v` prefix, such as `v3.0.0`, and push the tag.
928+
3. GitHub Actions verifies and publishes the parent POM, Java SDK, and OpenFeature provider to [GitHub Packages](https://github.com/orgs/featurevisor/packages?repo_name=featurevisor-java).
929+
4. Create the corresponding [GitHub release](https://github.com/featurevisor/featurevisor-java/releases).
922930

923931
## License
924932

0 commit comments

Comments
 (0)