transport

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2016 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const (
	PathPrefix                byte = byte('/')
	DefaultMaxSleepTime            = 1 * time.Second  // accept中间最大sleep interval
	DefaultMAXConnNum              = 50 * 1024 * 1024 // 默认最大连接数 50w
	DefaultHTTPRspBufferSize       = 1024
	DefaultTcpReadBufferSize       = 128 * 1024 // 64k
	DefaultTcpWriteBufferSize      = 512 * 1024 // 64k
)
View Source
const (
	REQ_Q_SIZE = 1 // http1.1形式的短连接,一次也只能处理一个请求,放大size无意义
)

Variables

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

Functions

This section is empty.

Types

type Client

type Client interface {
	Recv(*Message) error
	Send(*Message) error
	Close() error
}

type DialOption

type DialOption func(*DialOptions)

func WithPath

func WithPath(path string) DialOption

func WithStream

func WithStream() DialOption

Indicates whether this is a streaming connection

func WithTimeout

func WithTimeout(d time.Duration) DialOption

Timeout used when dialling the remote side

type DialOptions

type DialOptions struct {
	Stream  bool
	Timeout time.Duration
	Path    string

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type ListenOption

type ListenOption func(*ListenOptions)

type ListenOptions

type ListenOptions struct {

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Listener

type Listener interface {
	Addr() string
	Close() error
	Accept(func(Socket)) error
}

type Message

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

func (*Message) Reset

func (this *Message) Reset()

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

Addrs to use for transport

func Timeout

func Timeout(t time.Duration) Option

Timeout sets the timeout for Send/Recv execution

type Options

type Options struct {
	Addrs []string
	// Timeout sets the timeout for Send/Recv
	Timeout time.Duration

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Socket

type Socket interface {
	Recv(*Message) error
	Send(*Message) error
	Reset(c net.Conn, release func())
	Close() error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
}

type Transport

type Transport interface {
	Dial(addr string, opts ...DialOption) (Client, error)
	Listen(addr string, opts ...ListenOption) (Listener, error)
	String() string
}

Transport is an interface which is used for communication between services. It uses socket send/recv semantics and had various implementations {HTTP, RabbitMQ, NATS, ...}

func NewHTTPTransport

func NewHTTPTransport(opts ...Option) Transport

Jump to

Keyboard shortcuts

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