Skip to content

Commit

Permalink
Rename ConnectionBase#getContext() -> ConnectionBase#context()
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Sep 2, 2024
1 parent f42b5d2 commit aeff192
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
public void upgradeTo(ChannelHandlerContext ctx, FullHttpResponse upgradeResponse) throws Exception {

// Now we need to upgrade this to an HTTP2
VertxHttp2ConnectionHandler<Http2ClientConnection> handler = Http2ClientConnection.createHttp2ConnectionHandler(upgradedConnection.client, upgradingConnection.metrics, upgradingConnection.getContext(), true, upgradedConnection.current.metric(), upgradedConnection.current.authority(), upgradingConnection.pooled());
VertxHttp2ConnectionHandler<Http2ClientConnection> handler = Http2ClientConnection.createHttp2ConnectionHandler(upgradedConnection.client, upgradingConnection.metrics, upgradingConnection.context(), true, upgradedConnection.current.metric(), upgradedConnection.current.authority(), upgradingConnection.pooled());
upgradingConnection.channel().pipeline().addLast(handler);
handler.connectFuture().addListener(future -> {
if (!future.isSuccess()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void http1xConnected(HttpVersion version,
conn2.concurrencyChangeHandler(concurrency -> {
// Ignore
});
conn2.createStream(conn.getContext()).onComplete(ar -> {
conn2.createStream(conn.context()).onComplete(ar -> {
if (ar.succeeded()) {
HttpClientStream stream = ar.result();
stream.headHandler(resp -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public Future<Void> end() {

@Override
public Future<Void> sendFile(String filename, long offset, long length) {
return HttpUtils.resolveFile(conn.getContext(), filename, offset, length)
return HttpUtils.resolveFile(conn.context(), filename, offset, length)
.compose(file -> file
.pipe()
.endOnComplete(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ private ServerWebSocket acceptHandshake() {
return webSocketConn;
});
CompletableFuture<Void> latch = new CompletableFuture<>();
httpConn.getContext().execute(() -> {
httpConn.context().execute(() -> {
// Must be done on event-loop
pipeline.replace(VertxHandler.class, "handler", handler);
latch.complete(null);
Expand All @@ -520,7 +520,7 @@ private ServerWebSocket acceptHandshake() {
if (METRICS_ENABLED && httpConn.metrics != null) {
webSocket.setMetric(httpConn.metrics.connected(httpConn.metric(), requestMetric, this));
}
webSocket.registerHandler(httpConn.getContext().owner().eventBus());
webSocket.registerHandler(httpConn.context().owner().eventBus());
return webSocket;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void handleMessage(Object item) {
} else {
Buffer data = (Buffer) item;
int len = data.length();
conn.getContext().emit(null, v -> {
conn.context().emit(null, v -> {
if (stream.state().remoteSideOpen()) {
// Handle the HTTP upgrade case
// buffers are received by HTTP/1 and not accounted by HTTP/2
Expand All @@ -79,7 +79,7 @@ protected void handleMessage(Object item) {
this.priority = HttpUtils.DEFAULT_STREAM_PRIORITY;
this.isConnect = false;
this.writable = true;
this.outboundQueue = new OutboundMessageQueue<>(conn.getContext().nettyEventLoop()) {
this.outboundQueue = new OutboundMessageQueue<>(conn.context().nettyEventLoop()) {
// TODO implement stop drain to optimize flushes ?
@Override
public boolean test(MessageWrite msg) {
Expand Down Expand Up @@ -200,7 +200,7 @@ public boolean isNotWritable() {

public final Future<Void> writeFrame(int type, int flags, ByteBuf payload) {
Promise<Void> promise = context.promise();
EventLoop eventLoop = conn.getContext().nettyEventLoop();
EventLoop eventLoop = conn.context().nettyEventLoop();
if (eventLoop.inEventLoop()) {
doWriteFrame(type, flags, payload, promise);
} else {
Expand All @@ -210,7 +210,7 @@ public final Future<Void> writeFrame(int type, int flags, ByteBuf payload) {
}

public final void writeFrame(int type, int flags, ByteBuf payload, Promise<Void> promise) {
EventLoop eventLoop = conn.getContext().nettyEventLoop();
EventLoop eventLoop = conn.context().nettyEventLoop();
if (eventLoop.inEventLoop()) {
doWriteFrame(type, flags, payload, promise);
} else {
Expand All @@ -224,7 +224,7 @@ private void doWriteFrame(int type, int flags, ByteBuf payload, Promise<Void> pr

final void writeHeaders(Http2Headers headers, boolean first, boolean end, boolean checkFlush, Promise<Void> promise) {
if (first) {
EventLoop eventLoop = conn.getContext().nettyEventLoop();
EventLoop eventLoop = conn.context().nettyEventLoop();
if (eventLoop.inEventLoop()) {
doWriteHeaders(headers, end, checkFlush, promise);
} else {
Expand Down Expand Up @@ -288,7 +288,7 @@ void doWriteData(ByteBuf buf, boolean end, Promise<Void> promise) {
}

final void writeReset(long code) {
EventLoop eventLoop = conn.getContext().nettyEventLoop();
EventLoop eventLoop = conn.context().nettyEventLoop();
if (eventLoop.inEventLoop()) {
doWriteReset(code);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ default void runOnContext(Handler<Void> action) {
*/
EventExecutor executor();

default ContextInternal asEventLoopContext() {
if (threadingModel() == ThreadingModel.EVENT_LOOP) {
return this;
} else {
return owner().createEventLoopContext(nettyEventLoop(), workerPool(), classLoader());
}
}

/**
* Return the Netty EventLoop used by this Context. This can be used to integrate
* a Netty Server with a Vert.x runtime, specially the Context part.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public final ChannelHandlerContext channelHandlerContext() {
return chctx;
}

public final ContextInternal getContext() {
public final ContextInternal context() {
return context;
}

Expand Down

0 comments on commit aeff192

Please sign in to comment.