Help us shape the future of Go! Take the 2026 Go Developer Survey

trans

package
v0.16.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRemoteClosed = errors.New("remote connection closed")
)

Functions

func GetReadTimeout

func GetReadTimeout(cfg rpcinfo.RPCConfig) time.Duration

GetReadTimeout is to make the read timeout longer, it is better for proxy case to receive error resp.

func NewDefaultCliTransHandler

func NewDefaultCliTransHandler(opt *remote.ClientOption, ext Extension) (remote.ClientTransHandler, error)

NewDefaultCliTransHandler to provide default impl of cliTransHandler, it can be reused in netpoll, shm-ipc, framework-sdk extensions

func NewDefaultSvrTransHandler

func NewDefaultSvrTransHandler(opt *remote.ServerOption, ext Extension) (remote.ServerTransHandler, error)

NewDefaultSvrTransHandler to provide default impl of svrTransHandler, it can be reused in netpoll, shm-ipc, framework-sdk extensions

func NewListenConfig added in v0.4.0

func NewListenConfig(opt *remote.ServerOption) net.ListenConfig

NewListenConfig return an new net.ListenConfig.

Types

type Extension

type Extension interface {
	SetReadTimeout(ctx context.Context, conn net.Conn, cfg rpcinfo.RPCConfig, role remote.RPCRole)
	NewWriteByteBuffer(ctx context.Context, conn net.Conn, msg remote.Message) remote.ByteBuffer
	NewReadByteBuffer(ctx context.Context, conn net.Conn, msg remote.Message) remote.ByteBuffer
	ReleaseBuffer(remote.ByteBuffer, error) error
	IsTimeoutErr(error) bool
	// IsRemoteClosedErr is to check if the error caused by connection closed when output log or report metric
	IsRemoteClosedErr(error) bool
}

Extension is the interface that trans extensions need to implement, it will make the extension of trans more easily. Normally if we want to extend transport layer we need to implement the trans interfaces which are defined in trans_handler.go. In fact most code logic is similar in same mode, so the Extension interface is the the differentiated part that need to be implemented separately. The default common trans implement is in default_client_handler.go and default_server_handler.go.

type MuxEnabledFlag added in v0.3.3

type MuxEnabledFlag interface {
	MuxEnabled() bool
}

MuxEnabledFlag is used to determine whether a serverHandlerFactory is multiplexing.

type RemoteClosedError added in v0.16.4

type RemoteClosedError struct {
	Source RemoteClosedSource
	Cause  error
}

RemoteClosedError records the original error and how it was classified.

func IsRemoteClosedErr added in v0.16.4

func IsRemoteClosedErr(ext Extension, err error, conn net.Conn) *RemoteClosedError

IsRemoteClosedErr returns the remote-closed classification for err.

Besides the extension's error-based check, it also treats the error as remote-closed when conn is already inactive. This covers the case where an encoder flattens the underlying netpoll.ErrConnClosed into a plain string (e.g. gopkg/ttheader uses %s), which breaks the errors.Is chain so ext.IsRemoteClosedErr can no longer recognize it.

func (*RemoteClosedError) Error added in v0.16.4

func (e *RemoteClosedError) Error() string

Error implements the error interface.

func (*RemoteClosedError) Is added in v0.16.4

func (e *RemoteClosedError) Is(target error) bool

Is enables errors.Is(err, ErrRemoteClosed).

func (*RemoteClosedError) Unwrap added in v0.16.4

func (e *RemoteClosedError) Unwrap() error

Unwrap exposes the original error.

type RemoteClosedSource added in v0.16.4

type RemoteClosedSource int

RemoteClosedSource identifies how a remote-closed error was classified.

const (
	// RemoteClosedByExtension indicates the transport extension recognized the error.
	RemoteClosedByExtension RemoteClosedSource = iota
	// RemoteClosedByConnectionState indicates the connection was already inactive.
	RemoteClosedByConnectionState
)

func (RemoteClosedSource) String added in v0.16.4

func (s RemoteClosedSource) String() string

String implements fmt.Stringer for readable logging.

Directories

Path Synopsis
Package detection protocol detection, it is used for a scenario that switching KitexProtobuf to gRPC.
Package detection protocol detection, it is used for a scenario that switching KitexProtobuf to gRPC.
Package gonet contains server and client implementation for go net.
Package gonet contains server and client implementation for go net.
internal
Package invoke .
Package invoke .
Package nphttp2 transport powered by netpoll
Package nphttp2 transport powered by netpoll
codes
Package codes defines the canonical error codes used by gRPC.
Package codes defines the canonical error codes used by gRPC.
grpc
The files in grpc package are forked from gRPC[github.com/grpc/grpc-go], and we keep the original Copyright[Copyright 2017 gRPC authors] and License of gRPC for those files.
The files in grpc package are forked from gRPC[github.com/grpc/grpc-go], and we keep the original Copyright[Copyright 2017 gRPC authors] and License of gRPC for those files.
grpc/syscall
Package syscall provides functionalities that grpc uses to get low-level operating system stats/info.
Package syscall provides functionalities that grpc uses to get low-level operating system stats/info.
grpc/testutils/leakcheck
Package leakcheck contains functions to check leaked goroutines.
Package leakcheck contains functions to check leaked goroutines.
metadata
Package metadata define the structure of the metadata supported by gRPC library.
Package metadata define the structure of the metadata supported by gRPC library.
status
Package status implements errors returned by gRPC.
Package status implements errors returned by gRPC.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL