tnet

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 26 Imported by: 0

Documentation

Overview

Package tnet provides tRPC-Go transport implementation for tnet networking framework.

Index

Constants

This section is empty.

Variables

View Source
var DefaultClientTransport = NewClientTransport()

DefaultClientTransport is the default implementation of tnet client transport.

DefaultConnPool is default connection pool used by tnet.

View Source
var DefaultMuxPool = multiplex.NewPool(Dial)

DefaultMuxPool is default muxtiplex pool used by tnet.

View Source
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

func HealthChecker(pc *connpool.PoolConn, _ bool) bool

HealthChecker checks if connection healthy or not.

func NewClientTransport

func NewClientTransport() transport.ClientTransport

NewClientTransport creates a tnet client transport.

func NewConnectionPool

func NewConnectionPool(opts ...connpool.Option) connpool.Pool

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

func SetNumPollers(n int) error

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

type ServerTransportOptions struct {
	KeepAlivePeriod time.Duration
	ReusePort       bool
}

ServerTransportOptions is server transport options struct.

Directories

Path Synopsis
Package multiplex implements a connection pool that supports connection multiplexing.
Package multiplex implements a connection pool that supports connection multiplexing.

Jump to

Keyboard shortcuts

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