Skip to content

Commit

Permalink
Merge pull request #11 from swisspush/develop
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
lbovet authored Dec 28, 2022
2 parents 7f01c19 + 53b5bb9 commit 10976e6
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 4 deletions.
7 changes: 6 additions & 1 deletion kobuka-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>kobuka</artifactId>
<groupId>org.swisspush</groupId>
<version>1.1.3-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,6 +15,11 @@
<artifactId>kafka-clients</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.swisspush.kobuka.client;

import org.swisspush.kobuka.client.base.BaseCommonClientConfigBuilder;
import org.swisspush.kobuka.client.base.BaseStreamsConfigBuilder;

public class StreamsConfigBuilder extends BaseStreamsConfigBuilder<StreamsConfigBuilder> {

public StreamsConfigBuilder() {
}

public StreamsConfigBuilder(BaseStreamsConfigBuilder<?> parent) {
copyFrom(parent);
}

public StreamsConfigBuilder(BaseCommonClientConfigBuilder<?> parent) {
copyFrom(parent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.swisspush.kobuka.client.base;

import java.util.Map;
import java.util.function.Function;

/**
* Base class for custom builders. Do not use directly.
*/
public class BaseStreamsConfigBuilder<T extends BaseStreamsConfigBuilder<T> & ClientBuilderFunctions<T>>
extends AbstractStreamsConfigBuilder<T> implements ClientBuilderFunctions<T> {

public void copyFrom(BaseStreamsConfigBuilder<?> parent) {
configs.putAll(parent.configs);
}

public void copyFrom(BaseCommonClientConfigBuilder<?> parent) {
configs.putAll(parent.configs);
}

@Override
public Map<String, Object> build() {
return configs;
}

public <R> R transform(Function<BaseStreamsConfigBuilder<?>, R> fn) {
return fn.apply(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.config.types.Password;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.streams.StreamsConfig;
import org.junit.jupiter.api.Test;
import org.swisspush.kobuka.client.CommonClientConfigBuilder;
import org.swisspush.kobuka.client.ConsumerConfigBuilder;
import org.swisspush.kobuka.client.ProducerConfigBuilder;
import org.swisspush.kobuka.client.StreamsConfigBuilder;

import java.util.Arrays;
import java.util.Map;
Expand Down Expand Up @@ -81,10 +83,18 @@ public void testInheritance() {
.valueSerializer(StringDeserializer.class)
.build(ProducerConfig::new);

StreamsConfig streamsConfig =
commonConfigBuilder
.transform(StreamsConfigBuilder::new)
.applicationId("hello")
.build(StreamsConfig::new);

assertEquals(Arrays.asList("localhost:9092", "otherhost:9092"),
consumerConfig.getList(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
assertEquals(Arrays.asList("localhost:9092", "otherhost:9092"),
producerConfig.getList(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
assertEquals(Arrays.asList("localhost:9092", "otherhost:9092"),
streamsConfig.getList(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
}

/**
Expand Down
6 changes: 5 additions & 1 deletion kobuka-gen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>kobuka</artifactId>
<groupId>org.swisspush</groupId>
<version>1.1.3-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -14,6 +14,10 @@
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
</dependency>
<dependency>
<groupId>com.squareup</groupId>
<artifactId>javapoet</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.config.ConfigDef;
import org.apache.kafka.common.config.types.Password;
import org.apache.kafka.streams.StreamsConfig;

import javax.lang.model.element.Modifier;
import java.io.IOException;
Expand Down Expand Up @@ -37,12 +38,17 @@ public static void main(String[] args) throws IOException {
"AdminClientConfig",
stream(AdminClientConfig.configDef()),
rootDir);
generateBuilder(CLIENT_PACKAGE,
"StreamsConfig",
stream(StreamsConfig.configDef()),
rootDir);

// Generate common keys

Set<String> commonKeys = new HashSet<>(ConsumerConfig.configDef().configKeys().keySet());
commonKeys.retainAll(ProducerConfig.configDef().configKeys().keySet());
commonKeys.retainAll(AdminClientConfig.configDef().configKeys().keySet());
commonKeys.retainAll(StreamsConfig.configDef().configKeys().keySet());

Stream<Map.Entry<String, ConfigDef.ConfigKey>> commonConfigMap = AdminClientConfig.configDef().configKeys().entrySet().stream()
.filter(entry -> commonKeys.contains(entry.getKey()));
Expand Down
2 changes: 1 addition & 1 deletion kobuka-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>kobuka</artifactId>
<groupId>org.swisspush</groupId>
<version>1.1.3-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.swisspush</groupId>
<artifactId>kobuka</artifactId>
<packaging>pom</packaging>
<version>1.1.3-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<name>kobuka</name>
<description>Config Builders for Kafka. A fluent API for configuring kafka clients.</description>
<url>https://github.com/swisspush/kobuka</url>
Expand Down Expand Up @@ -109,6 +109,11 @@
<artifactId>kafka-clients</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
Expand Down

0 comments on commit 10976e6

Please sign in to comment.