Skip to content

Commit 882256a

Browse files
committed
PG command messages should be named PgCommandMessage instead of PgCommandCodec for more clarity.
1 parent 8fc7c9f commit 882256a

13 files changed

+48
-48
lines changed

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/PgSocketConnection.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
import io.vertx.core.internal.net.NetSocketInternal;
2828
import io.vertx.pgclient.PgConnectOptions;
2929
import io.vertx.pgclient.PgException;
30-
import io.vertx.pgclient.impl.codec.ExtendedQueryCommandCodec;
30+
import io.vertx.pgclient.impl.codec.ExtendedQueryPgCommandMessage;
3131
import io.vertx.pgclient.impl.codec.NoticeResponse;
3232
import io.vertx.pgclient.impl.codec.PgCodec;
33-
import io.vertx.pgclient.impl.codec.PgCommandCodec;
33+
import io.vertx.pgclient.impl.codec.PgCommandMessage;
3434
import io.vertx.pgclient.impl.codec.TxFailedEvent;
3535
import io.vertx.sqlclient.codec.CommandMessage;
3636
import io.vertx.sqlclient.codec.SocketConnectionBase;
@@ -179,12 +179,12 @@ protected <R> void doSchedule(CommandBase<R> cmd, Completable<R> handler) {
179179

180180
@Override
181181
protected CommandMessage<?, ?> toMessage(ExtendedQueryCommand<?> command, PreparedStatement preparedStatement) {
182-
return new ExtendedQueryCommandCodec<>((ExtendedQueryCommand<?>) command, preparedStatement);
182+
return new ExtendedQueryPgCommandMessage<>((ExtendedQueryCommand<?>) command, preparedStatement);
183183
}
184184

185185
@Override
186186
protected CommandMessage<?, ?> toMessage(CommandBase<?> command) {
187-
return PgCommandCodec.wrap(command);
187+
return PgCommandMessage.wrap(command);
188188
}
189189

190190
@Override

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CloseConnectionCommandCodec.java renamed to vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CloseConnectionPgCommandMessage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import io.vertx.sqlclient.spi.protocol.CloseConnectionCommand;
2020

21-
class CloseConnectionCommandCodec extends PgCommandCodec<Void, CloseConnectionCommand> {
21+
class CloseConnectionPgCommandMessage extends PgCommandMessage<Void, CloseConnectionCommand> {
2222

23-
static final CloseConnectionCommandCodec INSTANCE = new CloseConnectionCommandCodec();
23+
static final CloseConnectionPgCommandMessage INSTANCE = new CloseConnectionPgCommandMessage();
2424

25-
private CloseConnectionCommandCodec() {
25+
private CloseConnectionPgCommandMessage() {
2626
super(CloseConnectionCommand.INSTANCE);
2727
}
2828

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ClosePortalCommandCodec.java renamed to vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ClosePortalPgCommandMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import io.vertx.sqlclient.spi.protocol.CloseCursorCommand;
2020

21-
class ClosePortalCommandCodec extends PgCommandCodec<Void, CloseCursorCommand> {
21+
class ClosePortalPgCommandMessage extends PgCommandMessage<Void, CloseCursorCommand> {
2222

23-
ClosePortalCommandCodec(CloseCursorCommand cmd) {
23+
ClosePortalPgCommandMessage(CloseCursorCommand cmd) {
2424
super(cmd);
2525
}
2626

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CloseStatementCommandCodec.java renamed to vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/CloseStatementPgCommandMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import io.vertx.sqlclient.spi.protocol.CloseStatementCommand;
2020

21-
class CloseStatementCommandCodec extends PgCommandCodec<Void, CloseStatementCommand> {
21+
class CloseStatementPgCommandMessage extends PgCommandMessage<Void, CloseStatementCommand> {
2222

23-
CloseStatementCommandCodec(CloseStatementCommand cmd) {
23+
CloseStatementPgCommandMessage(CloseStatementCommand cmd) {
2424
super(cmd);
2525
}
2626

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ExtendedQueryCommandCodec.java renamed to vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/ExtendedQueryPgCommandMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
import io.vertx.sqlclient.codec.CommandResponse;
2424
import io.vertx.sqlclient.spi.protocol.ExtendedQueryCommand;
2525

26-
public class ExtendedQueryCommandCodec<R, C extends ExtendedQueryCommand<R>> extends QueryCommandBaseCodec<R, C> {
26+
public class ExtendedQueryPgCommandMessage<R, C extends ExtendedQueryCommand<R>> extends QueryBasePgCommandMessage<R, C> {
2727

2828
private PgEncoder encoder;
2929

3030
private static final String TABLE_SCHEMA_CHANGE_ERROR_MESSAGE_PATTERN = "bind message has \\d result formats but query has \\d columns";
3131

3232
private PgPreparedStatement ps;
3333

34-
public ExtendedQueryCommandCodec(C cmd, PreparedStatement ps) {
34+
public ExtendedQueryPgCommandMessage(C cmd, PreparedStatement ps) {
3535
super(cmd);
3636
this.rowDecoder = new RowResultDecoder<>(cmd.collector(), ((PgPreparedStatement)ps).rowDesc());
3737
this.ps = (PgPreparedStatement) ps;

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/InitCommandCodec.java renamed to vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/InitPgCommandMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
import io.vertx.sqlclient.codec.CommandResponse;
3030
import io.vertx.sqlclient.spi.protocol.InitCommand;
3131

32-
class InitCommandCodec extends PgCommandCodec<Connection, InitCommand> {
32+
class InitPgCommandMessage extends PgCommandMessage<Connection, InitCommand> {
3333

3434
private PgEncoder encoder;
3535
private String encoding;
3636
private ScramSession scramSession;
3737

38-
InitCommandCodec(InitCommand cmd) {
38+
InitPgCommandMessage(InitCommand cmd) {
3939
super(cmd);
4040
}
4141

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgCodec.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
public class PgCodec extends CombinedChannelDuplexHandler<PgDecoder, PgEncoder> {
2727

28-
private final ArrayDeque<PgCommandCodec<?, ?>> inflight = new ArrayDeque<>();
28+
private final ArrayDeque<PgCommandMessage<?, ?>> inflight = new ArrayDeque<>();
2929
private final PgDecoder decoder;
3030
private final PgEncoder encoder;
3131
private ChannelHandlerContext chctx;
@@ -37,7 +37,7 @@ public PgCodec(boolean useLayer7Proxy) {
3737
init(decoder, encoder);
3838
}
3939

40-
boolean add(PgCommandCodec<?, ?> codec) {
40+
boolean add(PgCommandMessage<?, ?> codec) {
4141
if (failure == null) {
4242
codec.decoder = decoder;
4343
inflight.add(codec);
@@ -48,11 +48,11 @@ boolean add(PgCommandCodec<?, ?> codec) {
4848
}
4949
}
5050

51-
PgCommandCodec<?, ?> peek() {
51+
PgCommandMessage<?, ?> peek() {
5252
return inflight.peek();
5353
}
5454

55-
PgCommandCodec<?, ?> poll() {
55+
PgCommandMessage<?, ?> poll() {
5656
return inflight.poll();
5757
}
5858

@@ -71,15 +71,15 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
7171
private void fail(Throwable cause) {
7272
if (failure == null) {
7373
failure = cause;
74-
for (Iterator<PgCommandCodec<?, ?>> it = inflight.iterator(); it.hasNext();) {
75-
PgCommandCodec<?, ?> cmdCodec = it.next();
74+
for (Iterator<PgCommandMessage<?, ?>> it = inflight.iterator(); it.hasNext();) {
75+
PgCommandMessage<?, ?> cmdCodec = it.next();
7676
it.remove();
7777
fail(cmdCodec, cause);
7878
}
7979
}
8080
}
8181

82-
private void fail(PgCommandCodec<?, ?> codec, Throwable cause) {
82+
private void fail(PgCommandMessage<?, ?> codec, Throwable cause) {
8383
codec.fail(cause);
8484
}
8585

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgCommandCodec.java renamed to vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgCommandMessage.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,31 @@
3232

3333
import java.util.Arrays;
3434

35-
public abstract class PgCommandCodec<R, C extends CommandBase<R>> extends CommandMessage<R, C> {
35+
public abstract class PgCommandMessage<R, C extends CommandBase<R>> extends CommandMessage<R, C> {
3636

37-
private static final Logger logger = LoggerFactory.getLogger(PgCommandCodec.class);
37+
private static final Logger logger = LoggerFactory.getLogger(PgCommandMessage.class);
3838

3939
PgDecoder decoder;
4040
PgException failure;
4141
R result;
4242

43-
PgCommandCodec(C cmd) {
43+
PgCommandMessage(C cmd) {
4444
super(cmd);
4545
}
4646

47-
public static PgCommandCodec<?, ?> wrap(CommandBase<?> cmd) {
47+
public static PgCommandMessage<?, ?> wrap(CommandBase<?> cmd) {
4848
if (cmd instanceof InitCommand) {
49-
return new InitCommandCodec((InitCommand) cmd);
49+
return new InitPgCommandMessage((InitCommand) cmd);
5050
} else if (cmd instanceof SimpleQueryCommand<?>) {
51-
return new SimpleQueryCodec<>((SimpleQueryCommand<?>) cmd);
51+
return new SimpleQueryPgCommandMessage<>((SimpleQueryCommand<?>) cmd);
5252
} else if (cmd instanceof PrepareStatementCommand) {
53-
return new PrepareStatementCommandCodec((PrepareStatementCommand) cmd);
53+
return new PrepareStatementPgCommandMessage((PrepareStatementCommand) cmd);
5454
} else if (cmd instanceof CloseConnectionCommand) {
55-
return CloseConnectionCommandCodec.INSTANCE;
55+
return CloseConnectionPgCommandMessage.INSTANCE;
5656
} else if (cmd instanceof CloseCursorCommand) {
57-
return new ClosePortalCommandCodec((CloseCursorCommand) cmd);
57+
return new ClosePortalPgCommandMessage((CloseCursorCommand) cmd);
5858
} else if (cmd instanceof CloseStatementCommand) {
59-
return new CloseStatementCommandCodec((CloseStatementCommand) cmd);
59+
return new CloseStatementPgCommandMessage((CloseStatementCommand) cmd);
6060
}
6161
throw new AssertionError("Invalid command " + cmd);
6262
}

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgDecoder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PgDecoder extends ChannelInboundHandlerAdapter {
4747
}
4848

4949
void fireCommandResponse(CommandResponse<?> commandResponse) {
50-
PgCommandCodec<?, ?> c = codec.poll();
50+
PgCommandMessage<?, ?> c = codec.poll();
5151
commandResponse.handler = (Completable) c.handler;
5252
chctx.fireChannelRead(commandResponse);
5353
}
@@ -203,8 +203,8 @@ private void decodeCommandComplete(ByteBuf in) {
203203
}
204204

205205
private void decodeDataRow(ByteBuf in) {
206-
PgCommandCodec<?, ?> cmdCodec = codec.peek();
207-
QueryCommandBaseCodec<?, ?> cmd = (QueryCommandBaseCodec<?, ?>) cmdCodec;
206+
PgCommandMessage<?, ?> cmdCodec = codec.peek();
207+
QueryBasePgCommandMessage<?, ?> cmd = (QueryBasePgCommandMessage<?, ?>) cmdCodec;
208208
int len = in.readUnsignedShort();
209209
cmd.rowDecoder.handleRow(len, in);
210210
}
@@ -253,7 +253,7 @@ private void decodeError(ChannelHandlerContext ctx, ByteBuf in) {
253253
decodeErrorOrNotice(response, in);
254254
switch (response.getCode()) {
255255
default:
256-
PgCommandCodec<?, ?> cmd = codec.peek();
256+
PgCommandMessage<?, ?> cmd = codec.peek();
257257
if (cmd != null) {
258258
cmd.handleErrorResponse(response);
259259
}
@@ -361,7 +361,7 @@ private void decodeErrorOrNotice(Response response, ByteBuf in) {
361361

362362
private void decodeAuthentication(ByteBuf in) {
363363
int type = in.readInt();
364-
PgCommandCodec<?, ?> pending = codec.peek();
364+
PgCommandMessage<?, ?> pending = codec.peek();
365365
switch (type) {
366366
case PgProtocolConstants.AUTHENTICATION_TYPE_OK: {
367367
pending.handleAuthenticationOk();

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgEncoder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private void enqueueMessage(Object msg, Object p1, Object p2, Object p3, int est
9696
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
9797
if (!closeSent) {
9898
CloseConnectionCommand cmd = CloseConnectionCommand.INSTANCE;
99-
PgCommandCodec<?, ?> codec = PgCommandCodec.wrap(cmd);
99+
PgCommandMessage<?, ?> codec = PgCommandMessage.wrap(cmd);
100100
codec.encode(this);
101101
}
102102
}
@@ -107,7 +107,7 @@ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
107107
capacityEstimate = 0;
108108
}
109109

110-
void write(PgCommandCodec<?, ?> cmd) {
110+
void write(PgCommandMessage<?, ?> cmd) {
111111
if (codec.add(cmd)) {
112112
cmd.encode(this);
113113
}
@@ -120,8 +120,8 @@ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
120120

121121
@Override
122122
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
123-
if (msg instanceof PgCommandCodec<?, ?>) {
124-
write((PgCommandCodec<?, ?>) msg);
123+
if (msg instanceof PgCommandMessage<?, ?>) {
124+
write((PgCommandMessage<?, ?>) msg);
125125
} else {
126126
super.write(ctx, msg, promise);
127127
}

0 commit comments

Comments
 (0)