github.com/cloudwego/kitex@v0.9.0/pkg/remote/trans/detection/noop.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 detection 18 19 import ( 20 "context" 21 "net" 22 23 "github.com/cloudwego/kitex/pkg/endpoint" 24 "github.com/cloudwego/kitex/pkg/klog" 25 "github.com/cloudwego/kitex/pkg/remote" 26 ) 27 28 var noopHandler = noopSvrTransHandler{} 29 30 type noopSvrTransHandler struct{} 31 32 func (noopSvrTransHandler) Write(ctx context.Context, conn net.Conn, send remote.Message) (nctx context.Context, err error) { 33 return ctx, nil 34 } 35 36 func (noopSvrTransHandler) Read(ctx context.Context, conn net.Conn, msg remote.Message) (nctx context.Context, err error) { 37 return ctx, nil 38 } 39 40 func (noopSvrTransHandler) OnRead(ctx context.Context, conn net.Conn) error { 41 return nil 42 } 43 func (noopSvrTransHandler) OnInactive(ctx context.Context, conn net.Conn) {} 44 func (noopSvrTransHandler) OnError(ctx context.Context, err error, conn net.Conn) { 45 if conn != nil { 46 klog.CtxErrorf(ctx, "KITEX: processing error, remoteAddr=%v, error=%s", conn.RemoteAddr(), err.Error()) 47 } else { 48 klog.CtxErrorf(ctx, "KITEX: processing error, error=%s", err.Error()) 49 } 50 } 51 52 func (noopSvrTransHandler) OnMessage(ctx context.Context, args, result remote.Message) (context.Context, error) { 53 return ctx, nil 54 } 55 func (noopSvrTransHandler) SetPipeline(pipeline *remote.TransPipeline) {} 56 func (noopSvrTransHandler) SetInvokeHandleFunc(inkHdlFunc endpoint.Endpoint) {} 57 func (noopSvrTransHandler) OnActive(ctx context.Context, conn net.Conn) (context.Context, error) { 58 return ctx, nil 59 }