/*
 * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package io.vertx.mysqlclient;

import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.impl.ContextInternal;
import io.vertx.core.impl.VertxInternal;
import io.vertx.mysqlclient.impl.MySQLPoolImpl;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.PoolOptions;

import static io.vertx.mysqlclient.MySQLConnectOptions.fromUri;

/**
 * A {@link Pool pool} of {@link MySQLConnection MySQL Connections}.
 */
@VertxGen
public interface MySQLPool extends Pool {

  
Like pool(String, PoolOptions) with a default poolOptions.
/** * Like {@link #pool(String, PoolOptions)} with a default {@code poolOptions}. */
static MySQLPool pool(String connectionUri) { return pool(connectionUri, new PoolOptions()); }
Like pool(MySQLConnectOptions, PoolOptions) with connectOptions build from connectionUri.
/** * Like {@link #pool(MySQLConnectOptions, PoolOptions)} with {@code connectOptions} build from {@code connectionUri}. */
static MySQLPool pool(String connectionUri, PoolOptions poolOptions) { return pool(fromUri(connectionUri), poolOptions); }
Like pool(Vertx, String, PoolOptions) with a default poolOptions..
/** * Like {@link #pool(Vertx, String,PoolOptions)} with a default {@code poolOptions}.. */
static MySQLPool pool(Vertx vertx, String connectionUri) { return pool(vertx, fromUri(connectionUri), new PoolOptions()); }
Like pool(Vertx, MySQLConnectOptions, PoolOptions) with connectOptions build from connectionUri.
/** * Like {@link #pool(Vertx, MySQLConnectOptions, PoolOptions)} with {@code connectOptions} build from {@code connectionUri}. */
static MySQLPool pool(Vertx vertx, String connectionUri, PoolOptions poolOptions) { return pool(vertx, fromUri(connectionUri), poolOptions); }
Create a connection pool to the MySQL server configured with the given connectOptions and poolOptions.
Params:
  • connectOptions – the options for the connection
  • poolOptions – the options for creating the pool
Returns:the connection pool
/** * Create a connection pool to the MySQL server configured with the given {@code connectOptions} and {@code poolOptions}. * * @param connectOptions the options for the connection * @param poolOptions the options for creating the pool * @return the connection pool */
static MySQLPool pool(MySQLConnectOptions connectOptions, PoolOptions poolOptions) { if (Vertx.currentContext() != null) { throw new IllegalStateException("Running in a Vertx context => use MySQLPool#pool(Vertx, MySQLConnectOptions, PoolOptions) instead"); } VertxOptions vertxOptions = new VertxOptions(); if (connectOptions.isUsingDomainSocket()) { vertxOptions.setPreferNativeTransport(true); } VertxInternal vertx = (VertxInternal) Vertx.vertx(vertxOptions); return MySQLPoolImpl.create(vertx.getOrCreateContext(), true, connectOptions, poolOptions); }
Like pool(MySQLConnectOptions, PoolOptions) with a specific Vertx instance.
/** * Like {@link #pool(MySQLConnectOptions, PoolOptions)} with a specific {@link Vertx} instance. */
static MySQLPool pool(Vertx vertx, MySQLConnectOptions connectOptions, PoolOptions poolOptions) { return MySQLPoolImpl.create((ContextInternal) vertx.getOrCreateContext(), false, connectOptions, poolOptions); } }