Documentation ¶
Overview ¶
Package tnet provides tRPC-Go transport implementation for tnet networking framework.
Index ¶
- Variables
- func Dial(opts *connpool.DialOptions) (net.Conn, error)
- func HealthChecker(pc *connpool.PoolConn, _ bool) bool
- func NewClientTransport() transport.ClientTransport
- func NewConnectionPool(opts ...connpool.Option) connpool.Pool
- func NewMuxPool(opts ...multiplex.OptPool) multiplexed.Pool
- func NewServerTransport(opts ...ServerTransportOption) transport.ServerTransport
- func SetNumPollers(n int) error
- type ServerTransportOption
- type ServerTransportOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultClientTransport = NewClientTransport()
DefaultClientTransport is the default implementation of tnet client transport.
var DefaultConnPool = connpool.NewConnectionPool( connpool.WithDialFunc(Dial), connpool.WithHealthChecker(HealthChecker), )
DefaultConnPool is default connection pool used by tnet.
var DefaultMuxPool = multiplex.NewPool(Dial)
DefaultMuxPool is default muxtiplex pool used by tnet.
var DefaultServerTransport = NewServerTransport(WithReusePort(true))
DefaultServerTransport is the default implementation of tnet server transport.
Functions ¶
func Dial ¶
func Dial(opts *connpool.DialOptions) (net.Conn, error)
Dial connects to the address on the named network.
func HealthChecker ¶
HealthChecker checks if connection healthy or not.
func NewClientTransport ¶
func NewClientTransport() transport.ClientTransport
NewClientTransport creates a tnet client transport.
func NewConnectionPool ¶
NewConnectionPool creates a new connection pool. Use it instead of connpool.NewConnectionPool when use tnet transport because it will dial tnet connection, otherwise error will occur.
func NewMuxPool ¶
func NewMuxPool(opts ...multiplex.OptPool) multiplexed.Pool
NewMuxPool creates a new multiplexing pool. Use it instead of mux.NewPool when use tnet transport because it will dial tnet connection.
func NewServerTransport ¶
func NewServerTransport(opts ...ServerTransportOption) transport.ServerTransport
NewServerTransport creates tnet server transport.
func SetNumPollers ¶
SetNumPollers sets the number of tnet pollers. Generally it is not actively used.
Types ¶
type ServerTransportOption ¶
type ServerTransportOption func(o *ServerTransportOptions)
ServerTransportOption is server transport option.
func WithKeepAlivePeriod ¶
func WithKeepAlivePeriod(d time.Duration) ServerTransportOption
WithKeepAlivePeriod sets the TCP keep alive interval.
func WithReusePort ¶
func WithReusePort(reuse bool) ServerTransportOption
WithReusePort returns a ServerTransportOption which enables reuse port or not.
type ServerTransportOptions ¶
ServerTransportOptions is server transport options struct.