Skip to content

Commit

Permalink
refactor: Rename repo and pointers to sdk-java (#127)
Browse files Browse the repository at this point in the history
* refactor: Rename repo and pointers to sdk-java

* fix: repo URL

* fix: Better snippet in README

* fix: README errors

* Update pom.xml

Co-authored-by: Nicklas Lundin <[email protected]>

* Update pom.xml

Co-authored-by: Nicklas Lundin <[email protected]>

---------

Co-authored-by: Nicklas Lundin <[email protected]>
  • Loading branch information
fabriziodemaria and nicklasl authored May 23, 2024
1 parent 4ffa37f commit 6c60de6
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Github Actions are set up that are able to:
In order to promote an uploaded version from **Staging** to **Release** (hence making it openly available on [Maven Central Search](https://central.sonatype.com/)) a user with the right credentials must login into the the [Sonatype UI](https://oss.sonatype.org/#welcome) and perform the release process manually.

#### After realeasing
After a release PR is merged, the main branch will stay at the release version (non-snapshot) until updated. Release please will create a PR ([example](https://github.com/spotify/confidence-openfeature-provider-java/pull/55)) that does this "snapshot bump". The recommendation is to merge that PR directly when possible.
After a release PR is merged, the main branch will stay at the release version (non-snapshot) until updated. Release please will create a PR ([example](https://github.com/spotify/confidence-sdk-java/pull/55)) that does this "snapshot bump". The recommendation is to merge that PR directly when possible.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
!.git*
/target/
*.iml
**dependency-reduced-pom.xml
68 changes: 30 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Confidence OpenFeature Java Provider
# Java Confidence SDK

Java library for the [Confidence](https://confidence.spotify.com/) feature flag provider.

The library includes a `Provider` for
the [OpenFeature Java SDK](https://openfeature.dev/docs/tutorials/getting-started/java), that can be
used to resolve feature flag values from the Confidence platform.

To learn more about the basic concepts (flags, targeting key, evaluation contexts),
the [OpenFeature reference documentation](https://openfeature.dev/docs/reference/intro) can be
useful.
Java library for [Confidence](https://confidence.spotify.com/).

## Install

Expand All @@ -18,14 +10,14 @@ useful.
```xml
<dependency>
<groupId>com.spotify.confidence</groupId>
<artifactId>openfeature-provider</artifactId>
<artifactId>sdk-java</artifactId>
<version>0.0.12-SNAPSHOT</version>
</dependency>
```
<!---x-release-please-end-->

#### Depending on a development snapshot
We deploy snapshots from the `main` branch to [Sonatype OSSRH](https://oss.sonatype.org/content/repositories/snapshots/com/spotify/confidence/openfeature-provider/).
We deploy snapshots from the `main` branch to [Sonatype OSSRH](https://oss.sonatype.org/content/repositories/snapshots/com/spotify/confidence/sdk-java/).
To use a snapshot, add the following repository to your `pom.xml`:
```xml
<distributionManagement>
Expand All @@ -38,34 +30,34 @@ To use a snapshot, add the following repository to your `pom.xml`:

## Usage

The provider is instantiated using a client token that is configured in the Confidence UI or via the
management API. After that all interaction with the feature flags happens using the OpenFeature client APIs.
The SDK is instantiated using a client secret that is configured in the Confidence UI or via the
management console.

### Resolving flags
Flag values are evaluated remotely and returned to the application:
```java
package com.spotify.confidence.openfeature;

import com.spotify.confidence.ConfidenceFeatureProvider;
import dev.openfeature.sdk.Client;
import dev.openfeature.sdk.MutableContext;
import dev.openfeature.sdk.OpenFeatureAPI;
import dev.openfeature.sdk.Value;
import java.util.Map;

public final class ResolveFlags {
final Confidence confidence = Confidence.builder("<CLIENT_TOKEN>").build();
confidence.setContext(Map.of("country", ConfidenceValue.of("SE")));
final String propertyValue =
confidence
.withContext(
Map.of(
"user_id", ConfidenceValue.of("<some-user-id>"),
"country", ConfidenceValue.of("SE")))
.getValue("flag-name.property-name", "defaultValue");
```

public static final String CLIENT_TOKEN = "<>";
### Tracking events
Events are emitted to the Confidence backend:
```java
confidence.track("my-event", ConfidenceValue.of(Map.of("field", ConfidenceValue.of("data"))));
```

public static void main(String[] args) {
final OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProvider(new ConfidenceFeatureProvider(CLIENT_TOKEN));
final Client client = api.getClient();
## OpenFeature
The library includes a `Provider` for
the [OpenFeature Java SDK](https://openfeature.dev/docs/tutorials/getting-started/java), that can be
used to resolve feature flag values from the Confidence platform.

final String targetingKey = "userId";
final Map<String, Value> context = Map.of("country", new Value("SE"));
final MutableContext ctx = new MutableContext(targetingKey, context);
final String propertyValue = client.getStringValue("flagName.propertyName", "defaultValue",
ctx);
System.out.println(propertyValue);
}
}
```
To learn more about the basic concepts (flags, targeting key, evaluation contexts),
the [OpenFeature reference documentation](https://openfeature.dev/docs/reference/intro) can be
useful.
2 changes: 1 addition & 1 deletion catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: confidence-openfeature-provider-java
name: sdk-java
spec:
type: library
owner: hawkeye
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</distributionManagement>

<groupId>com.spotify.confidence</groupId>
<artifactId>openfeature-provider</artifactId>
<artifactId>sdk-java</artifactId>
<version>0.0.12-SNAPSHOT</version>

<url>https://github.com/spotify/confidence-openfeature-provider-java</url>
<description>Confidence OpenFeature provider for Java</description>
<url>https://github.com/spotify/confidence-sdk-java</url>
<description>Confidence SDK for Java</description>

<properties>
<!-- Required by maven to compile Java 11 -->
Expand All @@ -35,32 +35,32 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<name>Confidence OpenFeature Provider</name>
<name>Confidence SDK</name>
<organization>
<name>com.spotify</name>
<url>https://github.com/spotify</url>
</organization>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/spotify/confidence-openfeature-provider-java/issues</url>
<url>https://github.com/spotify/confidence-sdk-java/issues</url>
</issueManagement>

<licenses>
<license>
<name>Apache License 2.0</name>
<url>https://github.com/spotify/confidence-openfeature-provider-java/blob/main/LICENSE</url>
<url>https://github.com/spotify/confidence-sdk-java/blob/main/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>https://github.com/spotify/confidence-openfeature-provider-java</url>
<url>https://github.com/spotify/confidence-sdk-java</url>
<connection>
scm:git:[email protected]:spotify/confidence-openfeature-provider-java.git
scm:git:[email protected]:spotify/confidence-sdk-java.git
</connection>
<developerConnection>
scm:git:[email protected]:spotify/confidence-openfeature-provider-java.git
scm:git:[email protected]:spotify/confidence-sdk-java.git
</developerConnection>
</scm>
<developers>
Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"bootstrap-sha": "188faf7e47b03bde3bf02c3521771301c77580d6",
"packages": {
".": {
"package-name": "com.spotify.confidence.openfeature-provider",
"package-name": "com.spotify.confidence.java-sdk",
"release-type": "maven",
"monorepo-tags": false,
"include-component-in-tag": false,
Expand Down

0 comments on commit 6c60de6

Please sign in to comment.