Skip to content

Instantly share code, notes, and snippets.

@limadelrey
Created January 21, 2021 01:04
Show Gist options
  • Save limadelrey/9f1ba6b519e29264ca0b5ff2a833682f to your computer and use it in GitHub Desktop.
Save limadelrey/9f1ba6b519e29264ca0b5ff2a833682f to your computer and use it in GitHub Desktop.
public class MainVerticle extends AbstractVerticle {
private static final Logger LOGGER = LoggerFactory.getLogger(MainVerticle.class);
@Override
public void start() {
final long start = System.currentTimeMillis();
deployMigrationVerticle(vertx)
.flatMap(migrationVerticleId -> deployApiVerticle(vertx))
.onSuccess(success -> LOGGER.info(LogUtils.RUN_APP_SUCCESSFULLY_MESSAGE.buildMessage(System.currentTimeMillis() - start)))
.onFailure(throwable -> LOGGER.error(throwable.getMessage()));
}
private Future<Void> deployMigrationVerticle(Vertx vertx) {
final DeploymentOptions options = new DeploymentOptions()
.setWorker(true)
.setWorkerPoolName("migrations-worker-pool")
.setInstances(1)
.setWorkerPoolSize(1);
return vertx.deployVerticle(MigrationVerticle.class.getName(), options)
.flatMap(vertx::undeploy);
}
private Future<String> deployApiVerticle(Vertx vertx) {
return vertx.deployVerticle(ApiVerticle.class.getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment