Skip to content

Commit b35901f

Browse files
authored
feat: Simplify idioms
* Simplify with more Vert.x-ish idioms * Keep line breaks Signed-off-by: Julien Ponge <jponge@redhat.com>
1 parent 65313bf commit b35901f

File tree

16 files changed

+519
-519
lines changed

16 files changed

+519
-519
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
trim_trailing_whitespace = true
8+
end_of_line = lf
9+
insert_final_newline = true

pom.xml

Lines changed: 107 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,116 +4,116 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>kafka.vertx</groupId>
8-
<artifactId>demo</artifactId>
9-
<version>0.0.2-SNAPSHOT</version>
7+
<groupId>kafka.vertx</groupId>
8+
<artifactId>demo</artifactId>
9+
<version>0.0.2-SNAPSHOT</version>
1010

11-
<properties>
12-
<kafka.version>2.3.0</kafka.version>
13-
<vertx.version>4.0.0-SNAPSHOT</vertx.version>
14-
<jackson-databind.version>2.10.2</jackson-databind.version>
15-
</properties>
16-
17-
<dependencyManagement>
18-
<dependencies>
19-
<dependency>
20-
<groupId>io.vertx</groupId>
21-
<artifactId>vertx-dependencies</artifactId>
22-
<version>${vertx.version}</version>
23-
<type>pom</type>
24-
<scope>import</scope>
25-
</dependency>
26-
</dependencies>
27-
</dependencyManagement>
11+
<properties>
12+
<kafka.version>2.3.0</kafka.version>
13+
<vertx.version>4.0.0-SNAPSHOT</vertx.version>
14+
<jackson-databind.version>2.10.2</jackson-databind.version>
15+
</properties>
2816

17+
<dependencyManagement>
2918
<dependencies>
30-
<dependency>
31-
<groupId>io.vertx</groupId>
32-
<artifactId>vertx-core</artifactId>
33-
</dependency>
34-
<dependency>
35-
<groupId>io.vertx</groupId>
36-
<artifactId>vertx-web</artifactId>
37-
</dependency>
38-
<dependency>
39-
<groupId>io.vertx</groupId>
40-
<artifactId>vertx-kafka-client</artifactId>
41-
</dependency>
42-
<dependency>
43-
<groupId>io.vertx</groupId>
44-
<artifactId>vertx-service-proxy</artifactId>
45-
</dependency>
46-
<dependency>
47-
<groupId>io.vertx</groupId>
48-
<artifactId>vertx-codegen</artifactId>
49-
<scope>provided</scope>
50-
</dependency>
51-
<dependency>
52-
<groupId>io.vertx</groupId>
53-
<artifactId>vertx-codegen</artifactId>
54-
<classifier>processor</classifier>
55-
</dependency>
56-
<dependency>
57-
<groupId>io.vertx</groupId>
58-
<artifactId>vertx-config</artifactId>
59-
</dependency>
60-
<dependency>
61-
<groupId>com.fasterxml.jackson.core</groupId>
62-
<artifactId>jackson-databind</artifactId>
63-
<version>${jackson-databind.version}</version>
64-
</dependency>
65-
<dependency>
66-
<groupId>ch.qos.logback</groupId>
67-
<artifactId>logback-classic</artifactId>
68-
<version>1.2.3</version>
69-
</dependency>
19+
<dependency>
20+
<groupId>io.vertx</groupId>
21+
<artifactId>vertx-dependencies</artifactId>
22+
<version>${vertx.version}</version>
23+
<type>pom</type>
24+
<scope>import</scope>
25+
</dependency>
7026
</dependencies>
27+
</dependencyManagement>
28+
29+
<dependencies>
30+
<dependency>
31+
<groupId>io.vertx</groupId>
32+
<artifactId>vertx-core</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>io.vertx</groupId>
36+
<artifactId>vertx-web</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>io.vertx</groupId>
40+
<artifactId>vertx-kafka-client</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>io.vertx</groupId>
44+
<artifactId>vertx-service-proxy</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.vertx</groupId>
48+
<artifactId>vertx-codegen</artifactId>
49+
<scope>provided</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>io.vertx</groupId>
53+
<artifactId>vertx-codegen</artifactId>
54+
<classifier>processor</classifier>
55+
</dependency>
56+
<dependency>
57+
<groupId>io.vertx</groupId>
58+
<artifactId>vertx-config</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>com.fasterxml.jackson.core</groupId>
62+
<artifactId>jackson-databind</artifactId>
63+
<version>${jackson-databind.version}</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>ch.qos.logback</groupId>
67+
<artifactId>logback-classic</artifactId>
68+
<version>1.2.3</version>
69+
</dependency>
70+
</dependencies>
7171

72-
<build>
73-
<pluginManagement>
74-
<plugins>
75-
<plugin>
76-
<artifactId>maven-compiler-plugin</artifactId>
77-
<version>3.8.1</version>
78-
<configuration>
79-
<source>1.8</source>
80-
<target>1.8</target>
81-
</configuration>
82-
</plugin>
83-
</plugins>
84-
</pluginManagement>
85-
<plugins>
86-
<plugin>
87-
<groupId>org.apache.maven.plugins</groupId>
88-
<artifactId>maven-shade-plugin</artifactId>
89-
<version>3.2.2</version>
90-
<executions>
91-
<execution>
92-
<phase>package</phase>
93-
<goals>
94-
<goal>shade</goal>
95-
</goals>
96-
<configuration>
97-
<transformers>
98-
<transformer
99-
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
100-
<manifestEntries>
101-
<Main-Class>kafka.vertx.demo.Main</Main-Class>
102-
</manifestEntries>
103-
</transformer>
104-
<transformer
105-
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
106-
<resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource>
107-
</transformer>
108-
</transformers>
109-
<artifactSet>
110-
</artifactSet>
111-
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-all.jar
112-
</outputFile>
113-
</configuration>
114-
</execution>
115-
</executions>
116-
</plugin>
117-
</plugins>
118-
</build>
72+
<build>
73+
<pluginManagement>
74+
<plugins>
75+
<plugin>
76+
<artifactId>maven-compiler-plugin</artifactId>
77+
<version>3.8.1</version>
78+
<configuration>
79+
<source>1.8</source>
80+
<target>1.8</target>
81+
</configuration>
82+
</plugin>
83+
</plugins>
84+
</pluginManagement>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-shade-plugin</artifactId>
89+
<version>3.2.2</version>
90+
<executions>
91+
<execution>
92+
<phase>package</phase>
93+
<goals>
94+
<goal>shade</goal>
95+
</goals>
96+
<configuration>
97+
<transformers>
98+
<transformer
99+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
100+
<manifestEntries>
101+
<Main-Class>kafka.vertx.demo.Main</Main-Class>
102+
</manifestEntries>
103+
</transformer>
104+
<transformer
105+
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
106+
<resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource>
107+
</transformer>
108+
</transformers>
109+
<artifactSet>
110+
</artifactSet>
111+
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-all.jar
112+
</outputFile>
113+
</configuration>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
</plugins>
118+
</build>
119119
</project>

src/main/java/kafka/vertx/demo/Main.java

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,56 +22,56 @@
2222

2323
public class Main {
2424

25-
private static String websocketVerticleName = "websocket";
26-
private static String producerVerticleName = "producer";
27-
private static String consumerVerticleName = "consumer";
28-
29-
private static final Logger logger = LoggerFactory.getLogger(Main.class);
30-
31-
public static void main(String[] args) {
32-
long startTime = currentTimeMillis();
33-
34-
// Set vertx timeout to deal with slow DNS connections
35-
System.setProperty(ResolverProvider.DISABLE_DNS_RESOLVER_PROP_NAME, "true");
36-
Vertx vertx = Vertx.vertx(
37-
new VertxOptions()
38-
.setWarningExceptionTime(10).setWarningExceptionTimeUnit(TimeUnit.SECONDS)
39-
.setMaxEventLoopExecuteTime(20).setMaxEventLoopExecuteTimeUnit((TimeUnit.SECONDS)));
40-
41-
Future<String> webSocketDeployment = vertx
42-
.deployVerticle(new WebsocketVerticle())
43-
.onSuccess(id -> verticleDeployed(websocketVerticleName, id))
44-
.onFailure(err -> verticleFailedToDeploy(websocketVerticleName, err));
45-
46-
Future<String> producerDeployment = vertx
47-
.deployVerticle(new ProducerVerticle())
48-
.onSuccess(id -> verticleDeployed(producerVerticleName, id))
49-
.onFailure(err -> verticleFailedToDeploy(producerVerticleName, err));
50-
51-
Future<String> consumerDeployment = vertx
52-
.deployVerticle(new ConsumerVerticle())
53-
.onSuccess(id -> verticleDeployed(consumerVerticleName, id))
54-
.onFailure(err -> verticleFailedToDeploy(consumerVerticleName, err));
55-
56-
// Create CompositeFuture to wait for verticles to start
57-
CompositeFuture.join(webSocketDeployment, producerDeployment, consumerDeployment)
58-
.onSuccess(res -> appStarted(currentTimeMillis() - startTime))
59-
.onFailure(Main::appFailedToStart);
60-
}
61-
62-
private static void appFailedToStart(Throwable t) {
63-
logger.error("❌ Application failed to start", t);
64-
}
65-
66-
private static void appStarted(long duration) {
67-
logger.info("✅ Application has started in {}ms, go to http://localhost:8080 to see the app running.", duration);
68-
}
69-
70-
private static void verticleDeployed(String name, String id) {
71-
logger.info("🚀 Verticle {} deployed: {}", name, id);
72-
}
73-
74-
private static void verticleFailedToDeploy(String name, Throwable err) {
75-
logger.error("❌ Verticle {} failed to deploy: {}", name, err.getMessage());
76-
}
25+
private static String websocketVerticleName = "websocket";
26+
private static String producerVerticleName = "producer";
27+
private static String consumerVerticleName = "consumer";
28+
29+
private static final Logger logger = LoggerFactory.getLogger(Main.class);
30+
31+
public static void main(String[] args) {
32+
long startTime = currentTimeMillis();
33+
34+
// Set vertx timeout to deal with slow DNS connections
35+
System.setProperty(ResolverProvider.DISABLE_DNS_RESOLVER_PROP_NAME, "true");
36+
Vertx vertx = Vertx.vertx(
37+
new VertxOptions()
38+
.setWarningExceptionTime(10).setWarningExceptionTimeUnit(TimeUnit.SECONDS)
39+
.setMaxEventLoopExecuteTime(20).setMaxEventLoopExecuteTimeUnit((TimeUnit.SECONDS)));
40+
41+
Future<String> webSocketDeployment = vertx
42+
.deployVerticle(new WebsocketVerticle())
43+
.onSuccess(id -> verticleDeployed(websocketVerticleName, id))
44+
.onFailure(err -> verticleFailedToDeploy(websocketVerticleName, err));
45+
46+
Future<String> producerDeployment = vertx
47+
.deployVerticle(new ProducerVerticle())
48+
.onSuccess(id -> verticleDeployed(producerVerticleName, id))
49+
.onFailure(err -> verticleFailedToDeploy(producerVerticleName, err));
50+
51+
Future<String> consumerDeployment = vertx
52+
.deployVerticle(new ConsumerVerticle())
53+
.onSuccess(id -> verticleDeployed(consumerVerticleName, id))
54+
.onFailure(err -> verticleFailedToDeploy(consumerVerticleName, err));
55+
56+
// Create CompositeFuture to wait for verticles to start
57+
CompositeFuture.join(webSocketDeployment, producerDeployment, consumerDeployment)
58+
.onSuccess(res -> appStarted(currentTimeMillis() - startTime))
59+
.onFailure(Main::appFailedToStart);
60+
}
61+
62+
private static void appFailedToStart(Throwable t) {
63+
logger.error("❌ Application failed to start", t);
64+
}
65+
66+
private static void appStarted(long duration) {
67+
logger.info("✅ Application has started in {}ms, go to http://localhost:8080 to see the app running.", duration);
68+
}
69+
70+
private static void verticleDeployed(String name, String id) {
71+
logger.info("🚀 Verticle {} deployed: {}", name, id);
72+
}
73+
74+
private static void verticleFailedToDeploy(String name, Throwable err) {
75+
logger.error("❌ Verticle {} failed to deploy: {}", name, err.getMessage());
76+
}
7777
}

src/main/java/kafka/vertx/demo/consumer/ConsumerService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
@ProxyGen
1414
public interface ConsumerService {
1515

16-
static ConsumerService createProxy(Vertx vertx, String address) {
17-
return new ConsumerServiceVertxEBProxy(vertx, address);
18-
}
16+
static ConsumerService createProxy(Vertx vertx, String address) {
17+
return new ConsumerServiceVertxEBProxy(vertx, address);
18+
}
1919

20-
void subscribe(String topicName, String eventBusId, Handler<AsyncResult<Void>> resultHandler);
20+
void subscribe(String topicName, String eventBusId, Handler<AsyncResult<Void>> resultHandler);
2121

22-
void pause(String topicName, Handler<AsyncResult<Void>> resultHandler);
22+
void pause(String topicName, Handler<AsyncResult<Void>> resultHandler);
2323

2424
}

0 commit comments

Comments
 (0)