transport

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDialTimeout = time.Second * 5
)

Functions

This section is empty.

Types

type Acceptor

type Acceptor interface {
	Addr() string

	Close() error

	Accept(func(Channel)) error
}

type AcceptorOption

type AcceptorOption func(*AcceptorOptions)

type AcceptorOptions

type AcceptorOptions struct {
	Context context.Context
}

type Channel

type Channel interface {
	Recv(*Message) error

	Send(*Message) error

	Close() error

	Local() string

	Remote() string
}

type Connector

type Connector interface {
	Channel
}

type ConnectorOption

type ConnectorOption func(*ConnectorOptions)

func WithStream

func WithStream() ConnectorOption

func WithTimeout

func WithTimeout(d time.Duration) ConnectorOption

type ConnectorOptions

type ConnectorOptions struct {
	Stream  bool
	Timeout time.Duration
	Context context.Context
}

type Message

type Message struct {
	Header map[string]string
	Body   []byte
}

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

func Secure

func Secure(b bool) Option

func TLSConfig

func TLSConfig(t *tls.Config) Option

func Timeout

func Timeout(t time.Duration) Option

type Options

type Options struct {
	Addrs     []string
	Secure    bool
	TLSConfig *tls.Config
	Timeout   time.Duration
	Context   context.Context
}

type Transport

type Transport interface {
	Init(...Option) error

	Options() Options

	Dial(addr string, opts ...ConnectorOption) (Connector, error)

	Listen(addr string, opts ...AcceptorOption) (Acceptor, error)

	String() string
}

Jump to

Keyboard shortcuts

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