Skip to content

Instantly share code, notes, and snippets.

@jdob
Created March 30, 2020 15:04
Show Gist options
  • Save jdob/2755558e26eae145e3aaaaf0bc78d25e to your computer and use it in GitHub Desktop.
Save jdob/2755558e26eae145e3aaaaf0bc78d25e to your computer and use it in GitHub Desktop.
public void start(Future<Void> done) {
Single<DataGridClient> single = DataGridClient.create(vertx, new DataGridConfiguration()
.setHost("eventstore-dg-hotrod")
.setPort(11333));
single.flatMap(client -> client.<String, String>getCache("users"))
.flatMap(cache -> cache.clear().andThen(Single.just(cache)))
.subscribe(
cache -> {
this.cache = cache;
LOGGER.info("User Simulator initialized");
configure(config());
vertx.eventBus().<JsonObject>consumer("configuration", m -> configure(m.body().getJsonObject("user-simulator")));
vertx.eventBus().<Boolean>consumer("user-simulator-toggle", b -> toggle(b.body()));
done.complete(null);
},
err -> {
LOGGER.error("Unable to initialize the User Simulator");
done.fail(err);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment