Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public EventBusGrpcClientCall(ContextInternal context, boolean localUnary, boole
this.inbound = remoteUnary && localUnary ? new UnaryInbound() : new StreamingInbound();
}

abstract class Outbound {
abstract Future<Void> write(GrpcFrame frame);
abstract Future<Void> end();
private interface Outbound {
Future<Void> write(GrpcFrame frame);
Future<Void> end();
}

class UnaryOutbound extends Outbound {
private class UnaryOutbound implements Outbound {

private GrpcMessage message;

@Override
Future<Void> write(GrpcFrame frame) {
public Future<Void> write(GrpcFrame frame) {
switch (frame.type()) {
case HEADERS:
GrpcHeadersFrame headersFrame = (GrpcHeadersFrame) frame;
Expand Down Expand Up @@ -138,9 +138,9 @@ private Future<Void> send(GrpcMessage message) {
}
}

class StreamingOutbound extends Outbound {
private class StreamingOutbound implements Outbound {
@Override
Future<Void> write(GrpcFrame frame) {
public Future<Void> write(GrpcFrame frame) {
switch (frame.type()) {
case HEADERS:
GrpcHeadersFrame headersFrame = (GrpcHeadersFrame) frame;
Expand Down Expand Up @@ -228,16 +228,14 @@ public void write() {
}
}

abstract class Inbound {

abstract Throwable handleReply(Message<Object> reply, String encoding, WireFormat wireFormat);

private interface Inbound {
Throwable handleReply(Message<Object> reply, String encoding, WireFormat wireFormat);
}

class StreamingInbound extends Inbound {
class StreamingInbound implements Inbound {

@Override
Throwable handleReply(Message<Object> reply, String encoding, WireFormat wireFormat) {
public Throwable handleReply(Message<Object> reply, String encoding, WireFormat wireFormat) {
MultiMap replyHeaders = reply.headers();
String serverAddress = replyHeaders.get(EventBusHeaders.SERVER_ADDRESS);
String initialWindowHeader = replyHeaders.get(EventBusHeaders.INITIAL_WINDOW);
Expand Down Expand Up @@ -265,10 +263,10 @@ Throwable handleReply(Message<Object> reply, String encoding, WireFormat wireFor
}
}

class UnaryInbound extends Inbound {
class UnaryInbound implements Inbound {

@Override
Throwable handleReply(Message<Object> reply, String encoding, WireFormat wireFormat) {
public Throwable handleReply(Message<Object> reply, String encoding, WireFormat wireFormat) {
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
MultiMap trailers = MultiMap.caseInsensitiveMultiMap();
EventBusHeaders.decodeMultimap(HEADER_PREFIX, reply.headers(), headers);
Expand Down Expand Up @@ -336,9 +334,6 @@ public void handle(TransportFrame frame, Message<Object> message) {
case MESSAGE:
emitFrameInbound(new DefaultGrpcMessageFrame(EventBusGrpcCodec.message(frame, encoding, wireFormat)));
break;
case WINDOW_UPDATE:
grantSendWindow(frame.getWindowUpdate().getDelta());
break;
case TRAILERS:
Trailers t = frame.getTrailers();
MultiMap trailers = MultiMap.caseInsensitiveMultiMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ private void dispatch(Message<Object> message) {
}
EventBusGrpcStreamBase stream = streams.get(frame.getStreamId());
if (stream != null) {
stream.handle(frame, message);
if (frame.getFrameCase() == TransportFrame.FrameCase.WINDOW_UPDATE) {
stream.updateOutboundWindow(frame.getWindowUpdate().getDelta());
} else {
stream.handle(frame, message);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,53 +43,50 @@ public EventBusGrpcServerCall(
this.outbound = localUnary && remoteUnary ? new UnaryOutbound() : new StreamingOutbound();
}

abstract class Inbound {
private interface Inbound {

abstract void init(MultiMap headers, Message<Object> message);
void init(MultiMap headers, Message<Object> message);

}

class UnaryInbound extends Inbound {
private class UnaryInbound implements Inbound {
@Override
void init(MultiMap headers, Message<Object> message) {
public void init(MultiMap headers, Message<Object> message) {
Buffer payload = EventBusGrpcCodec.decodeBody(message.body());
emitFrameInbound(new DefaultGrpcHeadersFrame(wireFormat, "identity", headers));
emitFrameInbound(new DefaultGrpcMessageFrame(GrpcMessage.message("identity", wireFormat, payload)));
emitEndInbound();
}
}

class StreamingInbound extends Inbound {
private class StreamingInbound implements Inbound {
@Override
void init(MultiMap headers, Message<Object> message) {
public void init(MultiMap headers, Message<Object> message) {
GrpcHeadersFrame frame = new DefaultGrpcHeadersFrame(wireFormat, "identity, ", headers);
emitFrameInbound(frame);
}
}

abstract class Outbound {

abstract void init(String address, Message<Object> msg);

abstract Future<Void> write(GrpcFrame frame);
abstract Future<Void> end();

private interface Outbound {
void init(String address, Message<Object> msg);
Future<Void> write(GrpcFrame frame);
Future<Void> end();
}

class UnaryOutbound extends Outbound {
private class UnaryOutbound implements Outbound {

private Message<Object> message;
private MultiMap headers;
private GrpcMessage encodedMessage;
private boolean replied;

@Override
void init(String address, Message<Object> msg) {
public void init(String address, Message<Object> msg) {
this.message = msg;
}

@Override
Future<Void> write(GrpcFrame frame) {
public Future<Void> write(GrpcFrame frame) {
switch (frame.type()) {
case HEADERS:
headers = ((GrpcHeadersFrame) frame).headers();
Expand All @@ -108,7 +105,7 @@ Future<Void> write(GrpcFrame frame) {
}

@Override
Future<Void> end() {
public Future<Void> end() {
return consumerContext.succeededFuture();
}

Expand All @@ -133,12 +130,12 @@ private Future<Void> handleTrailers(GrpcStatus status, String statusMessage, Grp
}
}

class StreamingOutbound extends Outbound {
private class StreamingOutbound implements Outbound {

private Future<Void> lastWrite;

@Override
void init(String address, Message<Object> msg) {
public void init(String address, Message<Object> msg) {
DeliveryOptions replyOptions = new DeliveryOptions()
.addHeader(EventBusHeaders.SERVER_ADDRESS, address)
.addHeader(EventBusHeaders.INITIAL_WINDOW, Integer.toString(DEFAULT_WINDOW));
Expand All @@ -147,7 +144,7 @@ void init(String address, Message<Object> msg) {
}

@Override
Future<Void> write(GrpcFrame frame) {
public Future<Void> write(GrpcFrame frame) {
Future<Void> written;
switch (frame.type()) {
case HEADERS:
Expand Down Expand Up @@ -187,9 +184,6 @@ public void handle(TransportFrame frame, Message<Object> message) {
case HALF_CLOSE:
emitEndInbound();
break;
case WINDOW_UPDATE:
grantSendWindow(frame.getWindowUpdate().getDelta());
break;
case CANCEL:
if (closed) {
break;
Expand Down
Loading
Loading