Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment API #5086

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Deployment API #5086

wants to merge 3 commits into from

Conversation

vietj
Copy link
Member

@vietj vietj commented Jan 31, 2024

Deployment API work-in-progress

Vertx has an API for deploying verticles designed when Vert.x was still prominently using callbacks. Unfortunately this API be changed much without breaking the API backward compatibility.

This is an attempt to provide a new API for Vert.x 5 that fits better with the Vert.x 4+ programming model (which is returning futures).

The new interface io.vertx.core.Deployment defines the lifecycle for deploying services in a vertx instance, it embraces Vert.x futures and Java functional interface style.

Future<String> fut = vertx.deploy(context -> vertx
  .createHttpServer()
  .requestHandler(req -> {
    req
      .response()
      .end("Hello World");
    }).listen(8080)
);

The deployment stop method provides a default implementation which can be overridden:

Future<String> fut = vertx.deploy(new Deployment() {
  HttpServer server;
  @Override
  public Future<?> start(Context context) {
    server = vertx.createHttpServer()
      .requestHandler(req -> {
        req.response().end("Hello World");
      });
    return server.listen(8080);
  }
  @Override
  public Future<?> stop(Context context) {
    return server.close();
  }
});

@vietj vietj added this to the 5.0.0 milestone Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant