All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.db2client.DB2Builder Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2017 Julien Viet
 *
 * 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
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package io.vertx.db2client;

import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.net.NetClientOptions;
import io.vertx.db2client.impl.Db2PoolOptions;
import io.vertx.db2client.spi.DB2Driver;
import io.vertx.sqlclient.*;
import io.vertx.sqlclient.impl.ClientBuilderBase;

import java.util.function.Supplier;

/**
 * Entry point for building DB2 clients.
 */
@VertxGen
public interface DB2Builder {

  /**
   * Build a pool with the specified {@code block} argument.
   * The {@code block} argument is usually a lambda that configures the provided builder
   * 

* Example usage: {@code Pool pool = PgBuilder.pool(builder -> builder.connectingTo(connectOptions));} * * @return the pool as configured by the code {@code block} */ static Pool pool(Handler> block) { return ClientBuilder.pool(DB2Driver.INSTANCE, block); } /** * Provide a builder for DB2 pool of connections *

* Example usage: {@code Pool pool = PgBuilder.pool().connectingTo(connectOptions).build()} */ static ClientBuilder pool() { return ClientBuilder.pool(DB2Driver.INSTANCE); } /** * Build a client backed by a connection pool with the specified {@code block} argument. * The {@code block} argument is usually a lambda that configures the provided builder *

* Example usage: {@code SqlClient client = PgBuilder.client(builder -> builder.connectingTo(connectOptions));} * * @return the client as configured by the code {@code block} */ static SqlClient client(Handler> handler) { ClientBuilder builder = client(); handler.handle(builder); return builder.build(); } /** * Provide a builder for DB2 client backed by a connection pool. *

* Example usage: {@code SqlClient client = PgBuilder.client().connectingTo(connectOptions).build()} */ static ClientBuilder client() { return new ClientBuilderBase(DB2Driver.INSTANCE) { @Override public ClientBuilder with(PoolOptions options) { if (options != null) { options = new Db2PoolOptions(options).setPipelined(true); } return super.with(options); } @Override protected SqlClient create(Vertx vertx, Supplier> databases, PoolOptions poolOptions, NetClientOptions transportOptions, Handler connectHandler) { return driver.createPool(vertx, databases, poolOptions, transportOptions, connectHandler); } }; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy