Performance tuning done
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.cygnus.cloud.database;
|
||||
|
||||
import io.vertx.sqlclient.Pool;
|
||||
import io.vertx.sqlclient.Row;
|
||||
import io.vertx.sqlclient.RowSet;
|
||||
import io.vertx.sqlclient.Tuple;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* Reactor boundary around the Vert.x PostgreSQL pool. Feature repositories
|
||||
* should use parameterized SQL and pass values through {@link Tuple}.
|
||||
*/
|
||||
@Service
|
||||
public class ReactiveDatabaseClient {
|
||||
|
||||
private final Pool pool;
|
||||
|
||||
public ReactiveDatabaseClient(Pool pool) {
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
public Mono<RowSet<Row>> query(String sql) {
|
||||
return Mono.fromCompletionStage(() -> pool.query(sql).execute().toCompletionStage());
|
||||
}
|
||||
|
||||
public Mono<RowSet<Row>> preparedQuery(String sql, Tuple parameters) {
|
||||
return Mono.fromCompletionStage(
|
||||
() -> pool.preparedQuery(sql).execute(parameters).toCompletionStage());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user