Skip to content

Instantly share code, notes, and snippets.

💭
Coding the Future

Julien Viet vietj

💭
Coding the Future
View GitHub Profile
View pgclient.adoc

Reactive PostgreSQL Client

The Reactive PostgreSQL Client is a client for PostgreSQL with a straightforward API focusing on scalability and low overhead.

The client is reactive and non blocking, allowing to handle many database connections with a single thread.

  • Event driven

  • Lightweight

View templates.adoc

SQL Client Templates

Table of Contents

SQL Client Templates is a small library designed to facilitate the execution of SQL queries.

Usage

To use SQL Client Templates add the following dependency to the dependencies section of your build descriptor:

  • Maven (in your pom.xml):

View reproducer.java
@Test
public void testResolveAbsoluteFile() throws Exception {
File folder = File.createTempFile("test", ".txt");
assertTrue(folder.delete());
assertTrue(folder.mkdirs());
folder.deleteOnExit(); // Cleanup
File f = new File(folder, "child.txt");
Files.write(f.toPath(), "the_child".getBytes());
File notFound = new File(folder, "not_found");
Thread thread = Thread.currentThread();
View foo.java
pool.begin(res -> {
if (res.succeeded()) {
// Get the transaction
Transaction tx = res.result();
// Various statements
tx.query("INSERT INTO Users (first_name,last_name) VALUES ('Julien','Viet')")
.execute(ar1 -> {
if (ar1.succeeded()) {
View gist:8770ff31a2850fc01aec5d4545e7a6ac
@VertxGen
public interface SqlTemplate<R> {
static SqlTemplate<RowSet<Row>> forQuery(SqlClient client, String template) {
Collector<Row, ?, SqlResult<Row>> collector = null;
Function<SqlResult<Row>, RowSet<Row>> bilto = null;
return new SqlTemplateImpl<SqlResult<Row>, RowSet<Row>>(client, collector, bilto, template);
}
View CustomKeyManagerFactory.java
public void customKeyManagerFactory() {
Vertx vertx = Vertx.vertx();
vertx.createHttpServer(new HttpServerOptions().setKeyCertOptions(new KeyCertOptions() {
@Override
public KeyManagerFactory getKeyManagerFactory(Vertx vertx) throws Exception {
throw new UnsupportedOperationException("Implement me");
}
@Override
public KeyCertOptions clone() {
throw new UnsupportedOperationException("Implement me");
View test.java
public class JDBCTxOp extends AbstractJDBCAction<Void> {
private final TxCommand op;
public JDBCTxOp(JDBCStatementHelper helper, TxCommand op, SQLOptions options) {
super(helper, options);
this.op = op;
}
@Override
View executeDirect.java
private <T> void executeDirect(ContextInternal ctx, AbstractJDBCAction<T> action, Handler<AsyncResult<T>> handler) {
getConnection(ctx, ar1 -> {
Future<T> fut = Future.future();
fut.setHandler(ar2 -> ctx.runOnContext(v -> handler.handle(ar2)));
if (ar1.succeeded()) {
JDBCConnectionImpl conn = (JDBCConnectionImpl) ar1.result();
Tracer tracer = ctx.owner().tracer();
Object trace;
if (tracer != null) {
trace = tracer.sendRequest(ctx.localContextData(), action);
View StatementBenchmarks.java
/*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View gist:300644441bc3d233bd84ea200dcdc7c3
Dear Committer:
The Eclipse Board of Directors approved changes to the Eclipse Intellectual
Property Policy on October 21, 2019. The most significant change relates to
how we will perform due diligence of leveraged Third Party Content (Section IV
B).
Motivation and Background:
The Eclipse IP Policy and Procedures date back to 2004. While we have made
You can’t perform that action at this time.