-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Richard Hightower edited this page Feb 18, 2017
·
2 revisions
Guava gets used by many libraries for its async support. Many NoSQL drivers use Guava, e.g., Cassandra.
Guava is JDK 1.6 backwards compatible.
Reakt provides composable promises that support lambda expressions, and a fluent API.
This bridge allows you to use Reakt's promises, reactive streams and callbacks to have a more modern Java experience with libs like Cassandra and other libs that use Guava.
futureToPromise(session.executeAsync(insertInto("Todo")
.value("id", todo.getId())
.value("createTime", todo.getCreateTime())
.value("name", todo.getName())
.value("description", todo.getDescription()))
).catchError(error -> {
serviceMgmt.increment("add.todo.fail");
serviceMgmt.increment("add.todo.fail." +
error.getClass().getName().toLowerCase());
recordCassandraError();
promise.reject("unable to add todo", error);
}).then(resultSet -> {
if (resultSet.wasApplied()) {
promise.resolve(true);
serviceMgmt.increment("add.todo.success");
} else {
promise.resolve(false);
serviceMgmt.increment("add.todo.fail.not.added");
}
}).invokeWithReactor(reactor, Duration.ofSeconds(10)))
<dependency>
<groupId>io.advantageous.reakt</groupId>
<artifactId>reakt-guava</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
compile 'io.advantageous.reakt:reakt-guava:3.0.0.RELEASE'
You can also use replay promises, all promises, any promises, and other features of Reakt to simplify async, reactive Java development.
Reakt gets used by QBit, and Conekt.