transport

package
v0.0.2-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Init(...ConnOption)
	Close() error
	Read(b []byte) (n int, e error)
	Write(b []byte) (n int, e error)
	LocalAddr() string
	RemoteAddr() string
}

type ConnOption

type ConnOption func(*ConnOptions)

func ReadDeadline

func ReadDeadline(t time.Time) ConnOption

func WriteDeadline

func WriteDeadline(t time.Time) ConnOption

type ConnOptions

type ConnOptions struct {
	ReadDeadline  time.Time
	WriteDeadline time.Time
}

//////////////////////////////////////////////////////////////////////////////

type Listener

type Listener interface {
	Accept() (Conn, error)
	Close() error
	Addr() string
}

type Option

type Option func(*Options)

func Context

func Context(ctx context.Context) Option

func DialTimeout

func DialTimeout(t time.Duration) Option

func TLSConfig

func TLSConfig(tls *tls.Config) Option

type Options

type Options struct {
	// dial timeout
	DialTimeout time.Duration

	// tls config
	TLSConfig *tls.Config

	// context
	Context context.Context
}

type Transport

type Transport interface {
	Init(...Option) error
	Options() Options
	Dial(addr string) (Conn, error)
	Listen(addr string) (Listener, error)
	String() string
}

func NewTransport

func NewTransport(opts ...Option) Transport

type Type

type Type int32
const (
	TCP Type = iota
	UDP
	HTTP1
	HTTP2
	WEBSOCKET
	QUIC
	RPC
	GRPC
)

func (Type) String

func (tt Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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