1 /*
2  * Copyright (C) 2019, HuntLabs
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 module hunt.database.driver.postgresql.PostgreSQLPool;
19 
20 import hunt.database.driver.postgresql.PostgreSQLConnectOptions;
21 import hunt.database.driver.postgresql.impl.PostgreSQLPoolImpl;
22 
23 import hunt.database.base.PoolOptions;
24 import hunt.database.base.SqlResult;
25 import hunt.database.base.RowSet;
26 import hunt.database.base.Row;
27 import hunt.database.base.Pool;
28 import hunt.database.base.Tuple;
29 import hunt.database.base.AsyncResult;
30 
31 
32 /**
33  * A pool of PostgreSQL connections.
34  *
35  * @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
36  */
37 interface PgPool : Pool {
38 
39     /**
40      * Like {@link #pool(PoolOptions)} with a default {@code poolOptions}.
41      */
42     // static PgPool pool() {
43     //     return pool(PgConnectOptions.fromEnv(), new PoolOptions());
44     // }
45 
46     /**
47      * Like {@link #pool(PgConnectOptions, PoolOptions)} with {@code connectOptions} build from the environment variables.
48      */
49     // static PgPool pool(PoolOptions poolOptions) {
50     //     return pool(PgConnectOptions.fromEnv(), poolOptions);
51     // }
52 
53     /**
54      * Like {@link #pool(string, PoolOptions)} with a default {@code poolOptions}.
55      */
56     // static PgPool pool(string connectionUri) {
57     //     return pool(connectionUri, new PoolOptions());
58     // }
59 
60     /**
61      * Like {@link #pool(PgConnectOptions, PoolOptions)} with {@code connectOptions} build from {@code connectionUri}.
62      */
63     // static PgPool pool(string connectionUri, PoolOptions poolOptions) {
64     //     return pool(PgConnectOptions.fromUri(connectionUri), poolOptions);
65     // }
66 
67     /**
68      * Like {@link #pool(Vertx, PgConnectOptions, PoolOptions)} with {@code connectOptions} build from the environment variables.
69      */
70     // static PgPool pool(Vertx vertx, PoolOptions poolOptions) {
71     //     return pool(vertx, PgConnectOptions.fromEnv(), poolOptions);
72     // }
73 
74     /**
75      * Like {@link #pool(Vertx, PgConnectOptions, PoolOptions)} with {@code connectOptions} build from {@code connectionUri}.
76      */
77     // static PgPool pool(Vertx vertx, string connectionUri, PoolOptions poolOptions) {
78     //     return pool(vertx, PgConnectOptions.fromUri(connectionUri), poolOptions);
79     // }
80 
81     /**
82      * Create a connection pool to the database configured with the given {@code connectOptions} and {@code poolOptions}.
83      *
84      * @param poolOptions the options for creating the pool
85      * @return the connection pool
86      */
87     static PgPool pool(PgConnectOptions connectOptions, PoolOptions poolOptions) {
88         return new PgPoolImpl(connectOptions, poolOptions);
89     }
90 
91     /**
92      * Like {@link #pool(PgConnectOptions, PoolOptions)} with a specific {@link Vertx} instance.
93      */
94     // static PgPool pool(Vertx vertx, PgConnectOptions connectOptions, PoolOptions poolOptions) {
95     //     return new PgPoolImpl(vertx.getOrCreateContext(), false, connectOptions, poolOptions);
96     // }
97 
98     // PgPool preparedQuery(string sql, RowSetHandler handler);
99 
100 
101     // <R> PgPool preparedQuery(string sql, Collector<Row, ?, R> collector, Handler!(AsyncResult!(SqlResult!(R))) handler);
102     // PgPool query(string sql, RowSetHandler handler);
103 
104 
105     // <R> PgPool query(string sql, Collector<Row, ?, R> collector, Handler!(AsyncResult!(SqlResult!(R))) handler);
106     // PgPool preparedQuery(string sql, Tuple arguments, RowSetHandler handler);
107 
108 
109     // <R> PgPool preparedQuery(string sql, Tuple arguments, Collector<Row, ?, R> collector, Handler!(AsyncResult!(SqlResult!(R))) handler);
110     // PgPool preparedBatch(string sql, List!(Tuple) batch, RowSetHandler handler);
111 
112 
113     // <R> PgPool preparedBatch(string sql, List!(Tuple) batch, Collector<Row, ?, R> collector, Handler!(AsyncResult!(SqlResult!(R))) handler);
114 
115 }