Skip to content

Commit

Permalink
Allow passing the vertx instance to the serdes (#5827)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlesarnal authored Jan 15, 2025
1 parent 757f05a commit bb8f914
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 395 deletions.
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<module>utils/converter</module>
<module>utils/kafka</module>
<module>utils/maven-plugin</module>
<module>utils/tools</module>
<module>utils/importexport</module>
<module>utils/exportConfluent</module>
<module>utils/protobuf-schema-utilities</module>
Expand Down Expand Up @@ -213,7 +212,6 @@
<!-- Dependency versions -->
<lombok.version>1.18.36</lombok.version>
<commons-codec.version>1.17.1</commons-codec.version>
<jboss-slf4j.version>1.2.1.Final</jboss-slf4j.version>
<apicurio-common-rest-client.version>0.1.18.Final</apicurio-common-rest-client.version>
<kafka-clients.version>3.6.0</kafka-clients.version>
<debezium.version>2.6.2.Final</debezium.version>
Expand Down Expand Up @@ -269,7 +267,7 @@

<!-- Kiota -->
<kiota.libs.version>1.8.2</kiota.libs.version>
<kiota.community.version>0.0.19</kiota.community.version>
<kiota.community.version>0.0.20</kiota.community.version>

<kiota.version>1.21.0</kiota.version>
<kiota.timeout>60</kiota.timeout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ public abstract class AbstractSchemaResolver<S, T> implements SchemaResolver<S,
protected String explicitArtifactId;
protected String explicitArtifactVersion;

protected Vertx vertx;
protected static Vertx vertx;
protected Vertx internalReference;
protected boolean resolveDereferenced;

@Override
public void configure(Map<String, ?> configs, SchemaParser<S, T> schemaParser) {
this.schemaParser = schemaParser;

if (this.vertx == null) {
this.vertx = Vertx.vertx();
if (vertx != null) {
internalReference = vertx;
}

if (internalReference == null) {
internalReference = Vertx.vertx();
}

this.config = new SchemaResolverConfig(configs);
Expand All @@ -72,7 +77,7 @@ public void configure(Map<String, ?> configs, SchemaParser<S, T> schemaParser) {
if (username != null) {
client = configureClientWithBasicAuth(config, baseUrl, username);
} else {
var adapter = new VertXRequestAdapter(this.vertx);
var adapter = new VertXRequestAdapter(internalReference);
adapter.setBaseUrl(baseUrl);
client = new RegistryClient(adapter);
}
Expand Down Expand Up @@ -275,8 +280,12 @@ public void reset() {
*/
@Override
public void close() throws IOException {
if (this.vertx != null) {
this.vertx.close();
if (internalReference != null) {
if (vertx == null) {
internalReference.close();
} else {
vertx = null;
}
}
}

Expand Down Expand Up @@ -304,7 +313,7 @@ private RequestAdapter configureAuthWithUrl(SchemaResolverConfig config, String
final String clientScope = config.getAuthClientScope();

return new VertXRequestAdapter(
buildOIDCWebClient(this.vertx, tokenEndpoint, clientId, clientSecret, clientScope));
buildOIDCWebClient(internalReference, tokenEndpoint, clientId, clientSecret, clientScope));
}

private RegistryClient configureClientWithBasicAuth(SchemaResolverConfig config, String registryUrl,
Expand All @@ -317,7 +326,8 @@ private RegistryClient configureClientWithBasicAuth(SchemaResolverConfig config,
"Missing registry auth password, set " + SchemaResolverConfig.AUTH_PASSWORD);
}

var adapter = new VertXRequestAdapter(buildSimpleAuthWebClient(this.vertx, username, password));
var adapter = new VertXRequestAdapter(
buildSimpleAuthWebClient(internalReference, username, password));

adapter.setBaseUrl(registryUrl);
return new RegistryClient(adapter);
Expand All @@ -340,4 +350,8 @@ protected void loadFromSearchedVersion(SearchedVersion version,
resultBuilder.artifactId(version.getArtifactId());
resultBuilder.version(String.valueOf(version.getVersion()));
}

public static void setVertx(Vertx vertx) {
AbstractSchemaResolver.vertx = vertx;
}
}
6 changes: 0 additions & 6 deletions schema-util/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logging</artifactId>
<version>${jboss-slf4j.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-json-org</artifactId>
Expand Down
6 changes: 0 additions & 6 deletions serdes/generic/serde-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logging</artifactId>
<version>${jboss-slf4j.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down
6 changes: 0 additions & 6 deletions serdes/kafka/serde-kafka-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logging</artifactId>
<version>${jboss-slf4j.version}</version>
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
Expand Down
6 changes: 1 addition & 5 deletions utils/kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logging</artifactId>
<version>${jboss-slf4j.version}</version>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-common</artifactId>
Expand Down
49 changes: 0 additions & 49 deletions utils/tools/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit bb8f914

Please sign in to comment.