Skip to content
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

refactor: Rename repo and pointers to sdk-java #127

Merged
merged 6 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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/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
nicklasl marked this conversation as resolved.
Show resolved Hide resolved
65 changes: 27 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,31 @@ 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 token that is configured in the Confidence UI or via the
management.
fabriziodemaria marked this conversation as resolved.
Show resolved Hide resolved

fabriziodemaria marked this conversation as resolved.
Show resolved Hide resolved
### 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.getValue(
fabriziodemaria marked this conversation as resolved.
Show resolved Hide resolved
"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/sdk-java</url>
fabriziodemaria marked this conversation as resolved.
Show resolved Hide resolved
<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/sdk-java/issues</url>
fabriziodemaria marked this conversation as resolved.
Show resolved Hide resolved
</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/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/sdk-java</url>
<connection>
scm:git:git@github.com:spotify/confidence-openfeature-provider-java.git
scm:git:git@github.com:spotify/sdk-java.git
fabriziodemaria marked this conversation as resolved.
Show resolved Hide resolved
</connection>
<developerConnection>
scm:git:git@github.com:spotify/confidence-openfeature-provider-java.git
scm:git:git@github.com:spotify/sdk-java.git
fabriziodemaria marked this conversation as resolved.
Show resolved Hide resolved
</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
Loading