Skip to content

Commit

Permalink
rpc_util: export a SharedBufferPool
Browse files Browse the repository at this point in the history
  • Loading branch information
hueypark committed Mar 15, 2023
1 parent 9390057 commit b1c6496
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type dialOptions struct {
defaultServiceConfig *ServiceConfig // defaultServiceConfig is parsed from defaultServiceConfigRawJSON.
defaultServiceConfigRawJSON *string
resolvers []resolver.Builder
sharedRecvBufferPool sharedRecvBufferPool
sharedRecvBufferPool SharedBufferPool
}

// DialOption configures how we set up the connection.
Expand Down Expand Up @@ -655,7 +655,7 @@ func WithResolvers(rs ...resolver.Builder) DialOption {
//
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
// later release.
func WithSharedRecvBufferPool(bufferPool sharedRecvBufferPool) DialOption {
func WithSharedRecvBufferPool(bufferPool SharedBufferPool) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.sharedRecvBufferPool = bufferPool
})
Expand Down
7 changes: 1 addition & 6 deletions rpc_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ type parser struct {
header [5]byte

// sharedRecvBufferPool is the pool of shared receive buffers.
sharedRecvBufferPool sharedRecvBufferPool
sharedRecvBufferPool SharedBufferPool
}

// recvMsg reads a complete gRPC message from the stream.
Expand Down Expand Up @@ -966,8 +966,3 @@ const (
)

const grpcUA = "grpc-go/" + Version

type sharedRecvBufferPool interface {
Get(length int) []byte
Put(*[]byte)
}
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ type serverOptions struct {
maxHeaderListSize *uint32
headerTableSize *uint32
numServerWorkers uint32
sharedRecvBufferPool sharedRecvBufferPool
sharedRecvBufferPool SharedBufferPool
}

var defaultServerOptions = serverOptions{
Expand Down Expand Up @@ -561,7 +561,7 @@ func NumStreamWorkers(numServerWorkers uint32) ServerOption {
//
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
// later release.
func SharedRecvBufferPool(bufferPool sharedRecvBufferPool) ServerOption {
func SharedRecvBufferPool(bufferPool SharedBufferPool) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.sharedRecvBufferPool = bufferPool
})
Expand Down
7 changes: 7 additions & 0 deletions shared_buffer_pool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package grpc

// SharedBufferPool is a pool of buffers that can be shared.
type SharedBufferPool interface {
Get(length int) []byte
Put(*[]byte)
}

0 comments on commit b1c6496

Please sign in to comment.