transport

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acceptor

type Acceptor interface {
	Accept() (Transport, error)
	Close() error
}

Acceptor defines transport acceptor

type Addr

type Addr = net.Addr

Addr alias to net.Addr

type Buffers

type Buffers struct {
	Buffers net.Buffers
	Indexes []int
}

Buffers to optimize message merging

type BuffersWriter

type BuffersWriter interface {
	Writev(buffs Buffers) (int64, error)
}

BuffersWriter defines writev for optimized syscall

type Factory

type Factory interface {

	// Schemes supported schemes.
	Schemes() Schemes

	// Connect to the peer with the specified address.
	Connect(options *Options) (Transport, error)

	// Listen for an address and accept the connection request.
	Listen(options *Options) (Acceptor, error)
}

Factory defines transport factory

type Option

type Option func(options *Options) error

Option defines option function

func WithAttachment added in v1.2.0

func WithAttachment(attachment interface{}) Option

WithAttachment a data associated with the Channel

func WithContext

func WithContext(ctx context.Context) Option

WithContext to hold other configure pass by context.WithValue

type Options

type Options struct {
	// In server side: listen address.
	// In client side: connect address.
	Address *url.URL

	// Other configure pass by context.WithValue
	Context context.Context

	// Attachment defines the object or data associated with the Channel
	Attachment interface{}
}

Options for transport

func ParseOptions

func ParseOptions(ctx context.Context, url string, options ...Option) (*Options, error)

ParseOptions parse options

func (*Options) AddressWithoutHost

func (lo *Options) AddressWithoutHost() string

AddressWithoutHost convert host:port to :port

func (*Options) Apply

func (lo *Options) Apply(options ...Option) error

Apply options

type Schemes

type Schemes []string

Schemes to define scheme list

func (Schemes) Add

func (ss Schemes) Add(scheme string) Schemes

Add scheme

func (Schemes) FixScheme added in v1.1.0

func (ss Schemes) FixScheme(u *url.URL) error

FixScheme to fix scheme

func (Schemes) Valid

func (ss Schemes) Valid(scheme string) bool

Valid scheme

func (Schemes) ValidURL

func (ss Schemes) ValidURL(address string) bool

ValidURL to check url scheme

type Transport

type Transport interface {
	net.Conn

	// BuffersWriter for optimized syscall
	BuffersWriter

	// Flush flush buffer.
	Flush() error

	// RawTransport raw transport object.
	RawTransport() interface{}
}

Transport defines a transport

func NewTransport added in v1.3.0

func NewTransport(conn net.Conn, readSize, writeSize int) Transport

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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