Skip to content

Commit

Permalink
refactor: Module split preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziodemaria committed May 20, 2024
1 parent 9bc883c commit ae3334c
Show file tree
Hide file tree
Showing 46 changed files with 62 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
# specific files), please put them in your ~/.global-gitignore and not here!
.*
!.git*
/target/
**/target/
*.iml
**/dependency-reduced-pom.xml
File renamed without changes.
14 changes: 14 additions & 0 deletions openfeature-provider/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

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

<artifactId>openfeature-provider</artifactId>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.spotify.confidence;

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>openfeature-provider</module>
<module>sdk-java</module>
</modules>

<distributionManagement>
<snapshotRepository>
Expand All @@ -14,7 +19,7 @@
</distributionManagement>

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

<url>https://github.com/spotify/confidence-openfeature-provider-java</url>
Expand Down Expand Up @@ -238,7 +243,7 @@
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource><directory>src/main/proto</directory></resource>
<resource><directory>confidence-sdk/src/main/proto</directory></resource>
</resources>
<plugins>
<plugin>
Expand Down Expand Up @@ -361,7 +366,7 @@
</dependency>
</dependencies>
<configuration combine.self="override">
<configLocation>src/main/resources/checkstyle.xml</configLocation>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
<logViolationsToConsole>true</logViolationsToConsole>
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.sdk-java",
"release-type": "maven",
"monorepo-tags": false,
"include-component-in-tag": false,
Expand Down
14 changes: 14 additions & 0 deletions sdk-java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

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

<artifactId>sdk-java</artifactId>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.io.Closer;
import com.spotify.confidence.shaded.flags.resolver.v1.ResolveFlagsResponse;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import java.io.Closeable;
Expand Down Expand Up @@ -98,7 +97,8 @@ public void send(String eventName, ConfidenceValue.Struct message) {
}
}

CompletableFuture<ResolveFlagsResponse> resolveFlags(String flagName) {
CompletableFuture<com.spotify.confidence.shaded.flags.resolver.v1.ResolveFlagsResponse>
resolveFlags(String flagName) {
return client().resolveFlags(flagName, getContext());
}

Expand Down Expand Up @@ -136,8 +136,8 @@ public void send(
}

@Override
public CompletableFuture<ResolveFlagsResponse> resolveFlags(
String flag, ConfidenceValue.Struct context) {
public CompletableFuture<com.spotify.confidence.shaded.flags.resolver.v1.ResolveFlagsResponse>
resolveFlags(String flag, ConfidenceValue.Struct context) {
return flagResolverClient.resolveFlags(flag, context);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.spotify.confidence;

import static com.spotify.confidence.shaded.flags.resolver.v1.FlagResolverServiceGrpc.*;

import com.google.common.base.Strings;
import com.google.protobuf.Struct;
import com.spotify.confidence.shaded.flags.resolver.v1.*;
import io.grpc.ManagedChannel;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand All @@ -11,29 +12,32 @@
public class GrpcFlagResolver implements FlagResolver {
private final ManagedChannel managedChannel;
private final String clientSecret;
private final Sdk sdk;
private final com.spotify.confidence.shaded.flags.resolver.v1.Sdk sdk;

private final FlagResolverServiceGrpc.FlagResolverServiceFutureStub stub;
private final FlagResolverServiceFutureStub stub;

public GrpcFlagResolver(String clientSecret, ManagedChannel managedChannel) {
if (Strings.isNullOrEmpty(clientSecret)) {
throw new IllegalArgumentException("clientSecret must be a non-empty string.");
}
this.clientSecret = clientSecret;
this.sdk =
Sdk.newBuilder()
.setId(SdkId.SDK_ID_JAVA_PROVIDER)
com.spotify.confidence.shaded.flags.resolver.v1.Sdk.newBuilder()
.setId(com.spotify.confidence.shaded.flags.resolver.v1.SdkId.SDK_ID_JAVA_PROVIDER)
.setVersion(SdkUtils.getSdkVersion())
.build();
this.managedChannel = managedChannel;
this.stub = FlagResolverServiceGrpc.newFutureStub(managedChannel);
this.stub =
com.spotify.confidence.shaded.flags.resolver.v1.FlagResolverServiceGrpc.newFutureStub(
managedChannel);
}

public CompletableFuture<ResolveFlagsResponse> resolve(String flag, Struct context) {
public CompletableFuture<com.spotify.confidence.shaded.flags.resolver.v1.ResolveFlagsResponse>
resolve(String flag, Struct context) {
return GrpcUtil.toCompletableFuture(
stub.withDeadlineAfter(10, TimeUnit.SECONDS)
.resolveFlags(
ResolveFlagsRequest.newBuilder()
com.spotify.confidence.shaded.flags.resolver.v1.ResolveFlagsRequest.newBuilder()
.setClientSecret(this.clientSecret)
.addAllFlags(List.of(flag))
.setEvaluationContext(context)
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit ae3334c

Please sign in to comment.