/** * Convenient method to create a record for a Mongo data source. * @param name the service name * @param location the location of the service (e.g. url, port...) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, JsonObject location, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.MongoDataSource.createRecord(name, location, metadata); return ret; }
/** * Convenient method to create a record for a Mongo data source. * @param name the service name * @param location the location of the service (e.g. url, port...) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, JsonObject location, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.MongoDataSource.createRecord(name, location, metadata); return ret; }
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.MongoDataSource j_receiver, java.lang.String name, java.util.Map<String, Object> location, java.util.Map<String, Object> metadata) { return io.vertx.servicediscovery.types.MongoDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.MongoDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null).toJson()) : null; } public static void getMongoClient(io.vertx.servicediscovery.types.MongoDataSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.mongo.MongoClient>> resultHandler) {
private Record createMongoRecord(DataSourceServiceConfiguration configuration) { return MongoDataSource.createRecord(configuration.getName(), configuration.getLocation(), configuration.getMetadata()); }
@Test public void testWithSugar() throws InterruptedException { Record record = MongoDataSource.createRecord("some-mongo-db", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")); discovery.publish(record, r -> { }); await().until(() -> record.getRegistration() != null); AtomicBoolean success = new AtomicBoolean(); MongoDataSource.getMongoClient(discovery, new JsonObject().put("name", "some-mongo-db"), ar -> { MongoClient client = ar.result(); client.getCollections(coll -> { client.close(); success.set(coll.succeeded()); }); }); await().untilAtomic(success, is(true)); } }
@Test public void testWithSugar() throws InterruptedException { Record record = MongoDataSource.createRecord("some-mongo-db", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")); discovery.publish(record, r -> { }); await().until(() -> record.getRegistration() != null); AtomicBoolean success = new AtomicBoolean(); MongoDataSource.getMongoClient(discovery, new JsonObject().put("name", "some-mongo-db"), ar -> { MongoClient client = ar.result(); client.getCollections(coll -> { client.close(); success.set(coll.succeeded()); }); }); await().untilAtomic(success, is(true)); } }
@Test public void test() throws InterruptedException { Record record = MongoDataSource.createRecord("some-mongo-db", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")); discovery.publish(record, (r) -> { }); await().until(() -> record.getRegistration() != null); AtomicReference<Record> found = new AtomicReference<>(); discovery.getRecord(new JsonObject().put("name", "some-mongo-db"), ar -> { found.set(ar.result()); }); await().until(() -> found.get() != null); ServiceReference service = discovery.getReference(found.get()); MongoClient client = service.get(); AtomicBoolean success = new AtomicBoolean(); client.getCollections(ar -> { success.set(ar.succeeded()); }); await().untilAtomic(success, is(true)); service.release(); // Just there to be sure we can call it twice service.release(); }
@Test public void test() throws InterruptedException { Record record = MongoDataSource.createRecord("some-mongo-db", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")); discovery.publish(record, (r) -> { }); await().until(() -> record.getRegistration() != null); AtomicReference<Record> found = new AtomicReference<>(); discovery.getRecord(new JsonObject().put("name", "some-mongo-db"), ar -> { found.set(ar.result()); }); await().until(() -> found.get() != null); ServiceReference service = discovery.getReference(found.get()); MongoClient client = service.get(); AtomicBoolean success = new AtomicBoolean(); client.getCollections(ar -> { success.set(ar.succeeded()); }); await().untilAtomic(success, is(true)); service.release(); // Just there to be sure we can call it twice service.release(); }
MongoDataSource.createRecord("my-mongo-data-source", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")),
MongoDataSource.createRecord("my-mongo-data-source", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")),
MongoDataSource.createRecord("my-mongo-data-source", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")),
MongoDataSource.createRecord("my-mongo-data-source", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")),
MongoDataSource.createRecord("my-mongo-data-source", new JsonObject().put("connection_string", "mongodb://localhost:12345"), new JsonObject().put("database", "some-raw-data")),