1 /* 2 * 3 * Copyright 2023 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 // Package experimental is a collection of experimental features that might 20 // have some rough edges to them. Housing experimental features in this package 21 // results in a user accessing these APIs as `experimental.Foo`, thereby making 22 // it explicit that the feature is experimental and using them in production 23 // code is at their own risk. 24 // 25 // All APIs in this package are experimental. 26 package experimental 27 28 import ( 29 "google.golang.org/grpc" 30 "google.golang.org/grpc/internal" 31 ) 32 33 // WithRecvBufferPool returns a grpc.DialOption that configures the use of 34 // bufferPool for parsing incoming messages on a grpc.ClientConn. Depending on 35 // the application's workload, this could result in reduced memory allocation. 36 // 37 // If you are unsure about how to implement a memory pool but want to utilize 38 // one, begin with grpc.NewSharedBufferPool. 39 // 40 // Note: The shared buffer pool feature will not be active if any of the 41 // following options are used: WithStatsHandler, EnableTracing, or binary 42 // logging. In such cases, the shared buffer pool will be ignored. 43 // 44 // Note: It is not recommended to use the shared buffer pool when compression is 45 // enabled. 46 func WithRecvBufferPool(bufferPool grpc.SharedBufferPool) grpc.DialOption { 47 return internal.WithRecvBufferPool.(func(grpc.SharedBufferPool) grpc.DialOption)(bufferPool) 48 } 49 50 // RecvBufferPool returns a grpc.ServerOption that configures the server to use 51 // the provided shared buffer pool for parsing incoming messages. Depending on 52 // the application's workload, this could result in reduced memory allocation. 53 // 54 // If you are unsure about how to implement a memory pool but want to utilize 55 // one, begin with grpc.NewSharedBufferPool. 56 // 57 // Note: The shared buffer pool feature will not be active if any of the 58 // following options are used: StatsHandler, EnableTracing, or binary logging. 59 // In such cases, the shared buffer pool will be ignored. 60 // 61 // Note: It is not recommended to use the shared buffer pool when compression is 62 // enabled. 63 func RecvBufferPool(bufferPool grpc.SharedBufferPool) grpc.ServerOption { 64 return internal.RecvBufferPool.(func(grpc.SharedBufferPool) grpc.ServerOption)(bufferPool) 65 } 66