Skip to content

Commit 4e41441

Browse files
committed
Extract public API into API package
Postgres is exposing custom API extensions such as CodecRegistrar and Notifications so we want to expose that API using a stable design.
1 parent 327741c commit 4e41441

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+490
-67
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
<version>3.0.1</version>
236236
<configuration>
237237
<excludePackageNames>
238-
io.r2dbc.postgresql.authentication,io.r2dbc.postgresql.client,io.r2dbc.postgresql.codec,io.r2dbc.postgresql.message,io.r2dbc.postgresql.util
238+
io.r2dbc.postgresql.authentication,io.r2dbc.postgresql.client,io.r2dbc.postgresql.message,io.r2dbc.postgresql.util
239239
</excludePackageNames>
240240
<links>
241241
<link>https://projectreactor.io/docs/core/release/api/</link>

src/main/java/io/r2dbc/postgresql/ExceptionFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.r2dbc.postgresql;
1818

19+
import io.r2dbc.postgresql.api.ErrorDetails;
20+
import io.r2dbc.postgresql.api.PostgresqlException;
1921
import io.r2dbc.postgresql.message.backend.BackendMessage;
2022
import io.r2dbc.postgresql.message.backend.ErrorResponse;
2123
import io.r2dbc.spi.R2dbcBadGrammarException;

src/main/java/io/r2dbc/postgresql/ExtendedQueryPostgresqlStatement.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.r2dbc.postgresql;
1818

19+
import io.r2dbc.postgresql.api.PostgresqlStatement;
1920
import io.r2dbc.postgresql.client.Binding;
2021
import io.r2dbc.postgresql.client.Client;
2122
import io.r2dbc.postgresql.client.ExtendedQueryMessageFlow;
@@ -27,7 +28,6 @@
2728
import io.r2dbc.postgresql.message.backend.NoData;
2829
import io.r2dbc.postgresql.util.Assert;
2930
import io.r2dbc.postgresql.util.GeneratedValuesUtils;
30-
import io.r2dbc.spi.Statement;
3131
import reactor.core.publisher.Flux;
3232

3333
import java.util.ArrayList;
@@ -115,19 +115,14 @@ public ExtendedQueryPostgresqlStatement bindNull(int index, Class<?> type) {
115115
}
116116

117117
@Override
118-
public Flux<PostgresqlResult> execute() {
118+
public Flux<io.r2dbc.postgresql.api.PostgresqlResult> execute() {
119119
if (this.generatedColumns == null) {
120120
return execute(this.sql);
121121
}
122122

123123
return execute(GeneratedValuesUtils.augment(this.sql, this.generatedColumns));
124124
}
125125

126-
@Override
127-
public Statement fetchSize(int rows) {
128-
return this;
129-
}
130-
131126
@Override
132127
public ExtendedQueryPostgresqlStatement returnGeneratedValues(String... columns) {
133128
Assert.requireNonNull(columns, "columns must not be null");
@@ -182,7 +177,7 @@ private static int expectedSize(String sql) {
182177
return count;
183178
}
184179

185-
private Flux<PostgresqlResult> execute(String sql) {
180+
private Flux<io.r2dbc.postgresql.api.PostgresqlResult> execute(String sql) {
186181
this.bindings.finish();
187182

188183
ExceptionFactory factory = ExceptionFactory.withSql(sql);

src/main/java/io/r2dbc/postgresql/NotificationResponseWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.r2dbc.postgresql;
1818

19+
import io.r2dbc.postgresql.api.Notification;
1920
import io.r2dbc.postgresql.message.backend.NotificationResponse;
2021

2122
/**

src/main/java/io/r2dbc/postgresql/PostgresqlBatch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/**
2929
* An implementation of {@link Batch} for executing a collection of statements in a batch against a PostgreSQL database.
3030
*/
31-
public final class PostgresqlBatch implements Batch {
31+
final class PostgresqlBatch implements io.r2dbc.postgresql.api.PostgresqlBatch {
3232

3333
private final Client client;
3434

@@ -54,7 +54,7 @@ public PostgresqlBatch add(String sql) {
5454
}
5555

5656
@Override
57-
public Flux<PostgresqlResult> execute() {
57+
public Flux<io.r2dbc.postgresql.api.PostgresqlResult> execute() {
5858
return new SimpleQueryPostgresqlStatement(this.client, this.codecs, String.join("; ", this.statements))
5959
.execute();
6060
}

src/main/java/io/r2dbc/postgresql/PostgresqlColumnMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
* An implementation of {@link ColumnMetadata} for a PostgreSQL database.
2929
*/
30-
public final class PostgresqlColumnMetadata implements ColumnMetadata {
30+
final class PostgresqlColumnMetadata implements io.r2dbc.postgresql.api.PostgresqlColumnMetadata {
3131

3232
private final Codecs codecs;
3333

src/main/java/io/r2dbc/postgresql/PostgresqlConnection.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package io.r2dbc.postgresql;
1818

19+
import io.r2dbc.postgresql.api.Notification;
20+
import io.r2dbc.postgresql.api.PostgresqlResult;
21+
import io.r2dbc.postgresql.api.PostgresqlStatement;
1922
import io.r2dbc.postgresql.client.Client;
2023
import io.r2dbc.postgresql.client.PortalNameSupplier;
2124
import io.r2dbc.postgresql.client.SimpleQueryMessageFlow;
@@ -46,7 +49,7 @@
4649
/**
4750
* An implementation of {@link Connection} for connecting to a PostgreSQL database.
4851
*/
49-
public final class PostgresqlConnection implements Connection {
52+
final class PostgresqlConnection implements io.r2dbc.postgresql.api.PostgresqlConnection {
5053

5154
private final Logger logger = LoggerFactory.getLogger(this.getClass());
5255

@@ -151,6 +154,7 @@ public PostgresqlStatement createStatement(String sql) {
151154
*
152155
* @return a hot {@link Flux} of {@link Notification Notifications}.
153156
*/
157+
@Override
154158
public Flux<Notification> getNotifications() {
155159

156160
NotificationAdapter notifications = this.notificationAdapter.get();

src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.r2dbc.postgresql.message.backend.AuthenticationMessage;
3131
import io.r2dbc.postgresql.util.Assert;
3232
import io.r2dbc.spi.ConnectionFactory;
33+
import io.r2dbc.spi.ConnectionFactoryMetadata;
3334
import io.r2dbc.spi.IsolationLevel;
3435
import io.r2dbc.spi.R2dbcException;
3536
import io.r2dbc.spi.R2dbcNonTransientResourceException;
@@ -83,7 +84,7 @@ private static Extensions getExtensions(PostgresqlConnectionConfiguration config
8384
}
8485

8586
@Override
86-
public Mono<PostgresqlConnection> create() {
87+
public Mono<io.r2dbc.postgresql.api.PostgresqlConnection> create() {
8788
SSLConfig sslConfig = this.configuration.getSslConfig();
8889
Predicate<Throwable> isAuthSpecificationError = e -> e instanceof ExceptionFactory.PostgresqlAuthenticationFailure;
8990
return this.tryConnectWithConfig(sslConfig)
@@ -112,7 +113,7 @@ public Mono<PostgresqlConnection> create() {
112113
return prepareConnection(connection, client.getByteBufAllocator(), codecs);
113114
})
114115
.onErrorResume(throwable -> this.closeWithError(client, throwable));
115-
}).onErrorMap(this::cannotConnect);
116+
}).onErrorMap(this::cannotConnect).cast(io.r2dbc.postgresql.api.PostgresqlConnection.class);
116117
}
117118

118119
private Mono<Client> tryConnectWithConfig(SSLConfig sslConfig) {
@@ -152,7 +153,7 @@ private Throwable cannotConnect(Throwable throwable) {
152153
}
153154

154155
@Override
155-
public PostgresqlConnectionFactoryMetadata getMetadata() {
156+
public ConnectionFactoryMetadata getMetadata() {
156157
return PostgresqlConnectionFactoryMetadata.INSTANCE;
157158
}
158159

src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* An implementation of {@link ConnectionFactoryMetadata} for a PostgreSQL database.
2323
*/
24-
public final class PostgresqlConnectionFactoryMetadata implements ConnectionFactoryMetadata {
24+
final class PostgresqlConnectionFactoryMetadata implements ConnectionFactoryMetadata {
2525

2626
/**
2727
* The name of the PostgreSQL database product.

src/main/java/io/r2dbc/postgresql/PostgresqlConnectionMetadata.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
package io.r2dbc.postgresql;
1818

1919
import io.r2dbc.postgresql.client.Version;
20-
import io.r2dbc.spi.ConnectionMetadata;
2120

2221
/**
2322
* Connection metadata for a connection connected to a PostgreSQL database.
2423
*/
25-
public final class PostgresqlConnectionMetadata implements ConnectionMetadata {
24+
final class PostgresqlConnectionMetadata implements io.r2dbc.postgresql.api.PostgresqlConnectionMetadata {
2625

2726
private final Version version;
2827

0 commit comments

Comments
 (0)