/** * Deploys a module. AsyncResultHandler<Void> */ public static void deployModule(Env env, StringValue moduleName, @Optional ArrayValue config, @Optional("1") NumberValue instances, @Optional Value handler) { boolean hasConfig = PhpTypes.notNull(config); boolean hasHandler = PhpTypes.notNull(handler); if (hasConfig && hasHandler) { PhpTypes.assertCallable(env, handler, "Handler argument to Vertx::deployModule() must be callable."); PhpVerticleFactory.container.deployModule(moduleName.toString(), PhpTypes.arrayToJson(env, config), instances.toInt(), HandlerFactory.<String>createAsyncGenericHandler(env, handler)); } else if (hasConfig) { PhpVerticleFactory.container.deployModule(moduleName.toString(), PhpTypes.arrayToJson(env, config), instances.toInt()); } else if (hasHandler) { PhpTypes.assertCallable(env, handler, "Handler argument to Vertx::deployModule() must be callable."); PhpVerticleFactory.container.deployModule(moduleName.toString(), instances.toInt(), HandlerFactory.<String>createAsyncGenericHandler(env, handler)); } else { PhpVerticleFactory.container.deployModule(moduleName.toString(), instances.toInt()); } }
final CountDownLatch latch = new CountDownLatch(1); final AtomicReference<Throwable> err = new AtomicReference<>(); container.deployModule(deploymentInfo.getString("module"), deploymentInfo.getObject("config"), deploymentInfo.getInteger("instances", 1), new Handler<AsyncResult<String>>() { @Override public void handle(AsyncResult<String> result) {
/** * Deploy a module programmatically * * @param moduleName The main of the module to deploy * @param config JSON config to provide to the module * @param instances The number of instances to deploy (defaults to 1) */ @Override public Promise<String> deployModule(String moduleName, JsonObject config, int instances) { final Deferred<String> d = when.defer(); container.deployModule(moduleName, config, instances, result -> { if (result.succeeded()) { d.resolve(result.result()); } else { d.reject(result.cause()); } }); return d.getPromise(); }
@Override public void handle(AsyncResult<Boolean> result) { if (result.failed()) { new DefaultFutureResult<String>(result.cause()).setHandler(doneHandler); } else if (result.result()) { new DefaultFutureResult<String>(new PlatformManagerException("Deployment already exists.")).setHandler(doneHandler); } else { container.deployModule(moduleName, config, instances, new Handler<AsyncResult<String>>() { @Override public void handle(AsyncResult<String> result) { if (result.succeeded()) { // Tell the other nodes of the cluster about the module for HA purposes addModuleToHA(deploymentID, result.result(), moduleName, config, instances, ha); } if (result.failed()) { new DefaultFutureResult<String>(result.cause()).setHandler(doneHandler); } else { new DefaultFutureResult<String>(deploymentID).setHandler(doneHandler); } } }); } } });