public StoreCRUDServiceImpl(Vertx vertx, JsonObject config) { this.client = MongoClient.createNonShared(vertx, config); }
/** * Create a Mongo client which maintains its own data source. * @param vertx the Vert.x instance * @param config the configuration * @return the client */ public static io.vertx.rxjava.ext.mongo.MongoClient createNonShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config) { io.vertx.rxjava.ext.mongo.MongoClient ret = io.vertx.rxjava.ext.mongo.MongoClient.newInstance(io.vertx.ext.mongo.MongoClient.createNonShared(vertx.getDelegate(), config)); return ret; }
/** * Create a Mongo client which maintains its own data source. * @param vertx the Vert.x instance * @param config the configuration * @return the client */ public static io.vertx.rxjava.ext.mongo.MongoClient createNonShared(io.vertx.rxjava.core.Vertx vertx, JsonObject config) { io.vertx.rxjava.ext.mongo.MongoClient ret = io.vertx.rxjava.ext.mongo.MongoClient.newInstance(io.vertx.ext.mongo.MongoClient.createNonShared(vertx.getDelegate(), config)); return ret; }
public static io.vertx.ext.mongo.MongoClient createNonShared(io.vertx.ext.mongo.MongoClient j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> config) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.mongo.MongoClient.createNonShared(vertx, config != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(config) : null)); } public static io.vertx.ext.mongo.MongoClient createShared(io.vertx.ext.mongo.MongoClient j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> config, java.lang.String dataSourceName) {
@Override public void start() throws Exception { // Create the client object service = new MongoServiceImpl(MongoClient.createNonShared(vertx, config())); // And register it on the event bus against the configured address String address = config().getString("address"); if (address == null) { throw new IllegalStateException("address field must be specified in config for client verticle"); } ProxyHelper.registerService(MongoService.class, vertx, service, address); }
private void initMongoClient(Handler<AsyncResult<Void>> handler) { try { Vertx vertx = getVertx(); JsonObject config = getConfig(); LOGGER.info("STARTING MONGO CLIENT with config " + config); mongoClient = shared ? MongoClient.createShared(vertx, config) : MongoClient.createNonShared(vertx, config); if (mongoClient == null) { handler.handle(Future.failedFuture(new InitException("No MongoClient created"))); } else { mongoClient.getCollections(resultHandler -> { if (resultHandler.failed()) { LOGGER.error("", resultHandler.cause()); handler.handle(Future.failedFuture(resultHandler.cause())); } else { LOGGER.info(String.format("found %d collections", resultHandler.result().size())); handler.handle(Future.succeededFuture()); } }); } } catch (Exception e) { handler.handle(Future.failedFuture(new InitException(e))); } }
@Override public MongoAuth createProvider(Vertx vertx) { MongoClient client; if (shared) { if (datasourceName != null) { client = MongoClient.createShared(vertx, config, datasourceName); } else { client = MongoClient.createShared(vertx, config); } } else { client = MongoClient.createNonShared(vertx, config); } JsonObject authConfig = new JsonObject(); MongoAuthOptionsConverter.toJson(this, authConfig); return MongoAuth.create(client, authConfig); }
mongo.awaitSuccess(120 * 1000); // Enough time for downloading the db JsonObject config = new JsonObject().put("connection_string", "mongodb://localhost:27018"); MongoClient client = MongoClient.createNonShared(vertx, config); MongoAuth auth = MongoAuth.create(client, new JsonObject()); Async ready = context.async();
@Override public MongoClient retrieve() { JsonObject result = record().getMetadata().copy(); result.mergeIn(record().getLocation()); if (config != null) { result.mergeIn(config); } if (result.getBoolean("shared", false)) { return MongoClient.createShared(vertx, result); } else { return MongoClient.createNonShared(vertx, result); } }
@Override public MongoClient retrieve() { JsonObject result = record().getMetadata().copy(); result.mergeIn(record().getLocation()); if (config != null) { result.mergeIn(config); } if (result.getBoolean("shared", false)) { return MongoClient.createShared(vertx, result); } else { return MongoClient.createNonShared(vertx, result); } }