-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
245 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 13 additions & 9 deletions
22
...etrics-examples/src/main/java/io/vertx/example/micrometer/verticles/EventbusConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
package io.vertx.example.micrometer.verticles; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.VerticleBase; | ||
|
||
/** | ||
* @author Joel Takvorian, [email protected] | ||
*/ | ||
public class EventbusConsumer extends AbstractVerticle { | ||
public class EventbusConsumer extends VerticleBase { | ||
@Override | ||
public void start() throws Exception { | ||
vertx.eventBus().<String>consumer("greeting", message -> { | ||
String greeting = message.body(); | ||
System.out.println("Received: " + greeting); | ||
Greetings.get(vertx) | ||
.onComplete(greetingResult -> message.reply(greetingResult.result())); | ||
}); | ||
public Future<?> start() { | ||
return vertx | ||
.eventBus() | ||
.<String>consumer("greeting", message -> { | ||
String greeting = message.body(); | ||
System.out.println("Received: " + greeting); | ||
Greetings.get(vertx) | ||
.onComplete(greetingResult -> message.reply(greetingResult.result())); | ||
}) | ||
.completion(); | ||
} | ||
} |
8 changes: 5 additions & 3 deletions
8
...etrics-examples/src/main/java/io/vertx/example/micrometer/verticles/EventbusProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
package io.vertx.example.micrometer.verticles; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.VerticleBase; | ||
|
||
/** | ||
* @author Joel Takvorian, [email protected] | ||
*/ | ||
public class EventbusProducer extends AbstractVerticle { | ||
public class EventbusProducer extends VerticleBase { | ||
|
||
@Override | ||
public void start() throws Exception { | ||
public Future<?> start() throws Exception { | ||
vertx.setPeriodic(1000, x -> { | ||
Greetings.get(vertx) | ||
.onComplete(greetingResult -> vertx.eventBus().send("greeting", greetingResult.result())); | ||
}); | ||
return super.start(); | ||
} | ||
} |
12 changes: 8 additions & 4 deletions
12
...metrics-examples/src/main/java/io/vertx/example/micrometer/verticles/SimpleWebServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
package io.vertx.example.micrometer.verticles; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.VerticleBase; | ||
import io.vertx.ext.web.Router; | ||
|
||
/** | ||
* @author Joel Takvorian, [email protected] | ||
*/ | ||
public class SimpleWebServer extends AbstractVerticle { | ||
public class SimpleWebServer extends VerticleBase { | ||
@Override | ||
public void start() throws Exception { | ||
public Future<?> start() throws Exception { | ||
Router router = Router.router(vertx); | ||
router.get("/").handler(ctx -> { | ||
Greetings.get(vertx).onComplete(greetingResult -> ctx.response().end(greetingResult.result())); | ||
}); | ||
vertx.createHttpServer().requestHandler(router).listen(8080); | ||
return vertx | ||
.createHttpServer() | ||
.requestHandler(router) | ||
.listen(8080); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
package io.vertx.example.micrometer.verticles; | ||
|
||
import io.micrometer.prometheus.PrometheusMeterRegistry; | ||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.VerticleBase; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.micrometer.backends.BackendRegistries; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* @author Joel Takvorian, [email protected] | ||
*/ | ||
public class WebServerForBoundPrometheus extends AbstractVerticle { | ||
public class WebServerForBoundPrometheus extends VerticleBase { | ||
|
||
@Override | ||
public void start() throws Exception { | ||
public Future<?> start() { | ||
Router router = Router.router(vertx); | ||
PrometheusMeterRegistry registry = (PrometheusMeterRegistry) BackendRegistries.getDefaultNow(); | ||
// Setup a route for metrics | ||
|
@@ -24,6 +23,9 @@ public void start() throws Exception { | |
router.get("/").handler(ctx -> { | ||
Greetings.get(vertx).onComplete(greetingResult -> ctx.response().end(greetingResult.result())); | ||
}); | ||
vertx.createHttpServer().requestHandler(router).listen(8080); | ||
return vertx | ||
.createHttpServer() | ||
.requestHandler(router) | ||
.listen(8080); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.