EarthChen commented on code in PR #10726: URL: https://github.com/apache/dubbo/pull/10726#discussion_r992104642
########## dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/buffer/WritableBuffer.java: ########## @@ -0,0 +1,65 @@ +/* + * Copyright 2015 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.remoting.buffer; + +/** + * An interface for a byte buffer that can only be written to. + * {@link WritableBuffer}s are a generic way to transfer bytes to + * the concrete network transports, like Netty and OkHttp. + */ +public interface WritableBuffer { + + /** + * Appends {@code length} bytes to the buffer from the source + * array starting at {@code srcIndex}. + * + * @throws IndexOutOfBoundsException + * if the specified {@code srcIndex} is less than {@code 0}, + * if {@code srcIndex + length} is greater than + * {@code src.length}, or + * if {@code length} is greater than {@link #writableBytes()} + */ + void write(byte[] src, int srcIndex, int length); + + /** + * Appends a single byte to the buffer. This is slow so don't call it. + */ + void write(byte b); + + + /** Review Comment: format ########## dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleClientStream.java: ########## @@ -131,33 +139,39 @@ public SocketAddress remoteAddress() { return parent.remoteAddress(); } - @Override - public ChannelFuture sendMessage(byte[] message, int compressFlag, boolean eos) { - final DataQueueCommand cmd = DataQueueCommand.createGrpcCommand(message, false, - compressFlag); - return this.writeQueue.enqueue(cmd) - .addListener(future -> { - if (!future.isSuccess()) { - cancelByLocal( - TriRpcStatus.INTERNAL.withDescription("Client write message failed") - .withCause(future.cause()) - ); - transportException(future.cause()); - } - } - ); + public Future<?> sendMessage(byte[] message) { + framer.writePayload(message); + return parent.newSucceededFuture(); Review Comment: future doesn't seem to make sense here. ########## dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/frame/Framer.java: ########## @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.rpc.protocol.tri.frame; + +import io.netty.channel.ChannelFuture; +import org.apache.dubbo.rpc.protocol.tri.compressor.Compressor; + +public interface Framer { Review Comment: format & comment.. ########## dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/command/FrameQueueCommand.java: ########## @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.rpc.protocol.tri.command; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import io.netty.handler.codec.http2.Http2StreamFrame; + +public class FrameQueueCommand extends QueuedCommand { Review Comment: What does this cmd do? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
