github.com/cloudwego/kitex@v0.9.0/pkg/remote/trans/invoke/conn_extension.go (about) 1 /* 2 * Copyright 2021 CloudWeGo Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package invoke 18 19 import ( 20 "context" 21 "net" 22 23 "github.com/cloudwego/kitex/pkg/remote" 24 "github.com/cloudwego/kitex/pkg/remote/trans" 25 "github.com/cloudwego/kitex/pkg/rpcinfo" 26 ) 27 28 func newIvkConnExtension() trans.Extension { 29 return &ivkConnExtension{} 30 } 31 32 type ivkConnExtension struct{} 33 34 // SetReadTimeout implements the trans.Extension interface. 35 func (e *ivkConnExtension) SetReadTimeout(ctx context.Context, conn net.Conn, cfg rpcinfo.RPCConfig, role remote.RPCRole) { 36 // do nothing 37 } 38 39 // NewWriteByteBuffer implements the trans.Extension interface. 40 func (e *ivkConnExtension) NewWriteByteBuffer(ctx context.Context, conn net.Conn, msg remote.Message) remote.ByteBuffer { 41 return conn.(Message).GetResponseWriterByteBuffer() 42 } 43 44 // NewReadByteBuffer implements the trans.Extension interface. 45 func (e *ivkConnExtension) NewReadByteBuffer(ctx context.Context, conn net.Conn, msg remote.Message) remote.ByteBuffer { 46 return conn.(Message).GetRequestReaderByteBuffer() 47 } 48 49 // ReleaseBuffer implements the trans.Extension interface. 50 func (e *ivkConnExtension) ReleaseBuffer(remote.ByteBuffer, error) error { 51 // do nothing, user will keep buffer 52 return nil 53 } 54 55 // IsTimeoutErr implements the trans.Extension interface. 56 func (e *ivkConnExtension) IsTimeoutErr(err error) bool { 57 return false 58 } 59 60 // IsRemoteClosedErr implements the trans.Extension interface. 61 func (e *ivkConnExtension) IsRemoteClosedErr(err error) bool { 62 return false 63 }