clientpipeline

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDNSCacheDuration = time.Minute

DefaultDNSCacheDuration is the duration for caching resolved TCP addresses by Dial* functions.

View Source
const DefaultDialTimeout = 3 * time.Second

DefaultDialTimeout is timeout used by Dial and DialDualStack for establishing TCP connections.

View Source
const DefaultMaxConnsPerHost = 512
View Source
const DefaultMaxIdemponentCallAttempts = 5
View Source
const DefaultMaxIdleConnDuration = 10 * time.Second
View Source
const DefaultMaxPendingRequests = 1024

Variables

View Source
var (
	ErrNoFreeConns      = errors.New("no free connections available to host")
	ErrConnectionClosed = errors.New("the server closed connection before returning the first response byte. " +
		"Make sure the server returns 'Connection: close' response header before closing the connection")
	// ErrGetOnly is returned when server expects only GET requests,
	// but some other type of request came (Server.GetOnly option is true).
	ErrGetOnly = errors.New("non-GET request received")
)
View Source
var (
	HTTP_1_0 = Version{Major: 1, Minor: 0}
	HTTP_1_1 = Version{Major: 1, Minor: 1}
)
View Source
var ErrDialTimeout = errors.New("dialing to the given TCP address timed out")

ErrDialTimeout is returned when TCP dialing is timed out.

View Source
var ErrPipelineOverflow = errors.New("pipelined requests' queue has been overflown. Increase MaxConns and/or MaxPendingRequests")
View Source
var ErrTLSHandshakeTimeout = errors.New("tls handshake timed out")

ErrTLSHandshakeTimeout indicates there is a timeout from tls handshake.

View Source
var (
	ErrTimeout = &timeoutError{}
)

Functions

func Dial

func Dial(addr string) (net.Conn, error)

func DialDualStack

func DialDualStack(addr string) (net.Conn, error)

func DialDualStackTimeout

func DialDualStackTimeout(addr string, timeout time.Duration) (net.Conn, error)

func DialTimeout

func DialTimeout(addr string, timeout time.Duration) (net.Conn, error)

Types

type DialFunc

type DialFunc func(addr string) (net.Conn, error)
type Header struct {
	Key   string
	Value string
}

Header represents a HTTP header.

type PipeConns

type PipeConns struct {
	// contains filtered or unexported fields
}

func NewPipeConns

func NewPipeConns() *PipeConns

func (*PipeConns) Close

func (pc *PipeConns) Close() error

Close closes pipe connections.

func (*PipeConns) Conn1

func (pc *PipeConns) Conn1() net.Conn

func (*PipeConns) Conn2

func (pc *PipeConns) Conn2() net.Conn

type PipelineClient

type PipelineClient struct {
	Addr                string
	MaxConns            int
	MaxPendingRequests  int
	MaxBatchDelay       time.Duration
	Dial                DialFunc
	DialDualStack       bool
	IsTLS               bool
	TLSConfig           *tls.Config
	MaxIdleConnDuration time.Duration
	ReadBufferSize      int
	WriteBufferSize     int
	ReadTimeout         time.Duration
	WriteTimeout        time.Duration
	// contains filtered or unexported fields
}

func (*PipelineClient) Do

func (c *PipelineClient) Do(req *Request, resp *Response) error

func (*PipelineClient) PendingRequests

func (c *PipelineClient) PendingRequests() int

type Request

type Request struct {
	AutomaticContentLength bool
	AutomaticHost          bool
	Method                 string
	Path                   string
	Query                  []string
	Version

	Headers []Header

	Body io.Reader
}

Request represents a complete HTTP request.

func ToRequest

func ToRequest(method string, path string, query []string, headers map[string][]string, body io.Reader) *Request

func (*Request) ContentLength

func (r *Request) ContentLength() int64

ContentLength returns the length of the body. If the body length is not known ContentLength will return -1.

func (*Request) Write

func (r *Request) Write(w *bufio.Writer) error

type Resolver

type Resolver interface {
	LookupIPAddr(context.Context, string) (names []net.IPAddr, err error)
}

Resolver represents interface of the tcp resolver.

type Response

type Response struct {
	Version
	Status
	Headers []Header

	Body io.Reader
	// contains filtered or unexported fields
}

Response represents an RFC2616 response.

func (*Response) CloseRequested

func (r *Response) CloseRequested() bool

CloseRequested returns if Reason includes a Connection: close header.

func (*Response) ContentLength

func (r *Response) ContentLength() int64

ContentLength returns the length of the body. If the body length is not known ContentLength will return -1.

func (*Response) Read

func (resp *Response) Read(r *bufio.Reader) error

func (*Response) ReadBody

func (resp *Response) ReadBody(r *bufio.Reader) io.Reader

func (*Response) ReadHeader

func (resp *Response) ReadHeader(r *bufio.Reader) (string, string, bool, error)

ReadHeader reads a http header.

func (*Response) ReadStatusCode

func (resp *Response) ReadStatusCode(r *bufio.Reader) (int, error)

ReadStatusCode reads the HTTP status code from the wire.

func (*Response) ReadStatusLine

func (resp *Response) ReadStatusLine(r *bufio.Reader) (Version, int, string, error)

ReadStatusLine reads the status line.

func (*Response) ReadVersion

func (resp *Response) ReadVersion(r *bufio.Reader) (Version, error)

func (*Response) TransferEncoding

func (r *Response) TransferEncoding() string

TransferEncoding returns the transfer encoding this message was transmitted with. If not is specified by the sender, "identity" is assumed.

type RetryIfFunc

type RetryIfFunc func(request *Request) bool

type Status

type Status struct {
	Code   int
	Reason string
}

Status represents an HTTP status code.

type TCPDialer

type TCPDialer struct {
	Concurrency int
	LocalAddr   *net.TCPAddr
	Resolver    Resolver
	// contains filtered or unexported fields
}

TCPDialer contains options to control a group of Dial calls.

func (*TCPDialer) Dial

func (d *TCPDialer) Dial(addr string) (net.Conn, error)

func (*TCPDialer) DialDualStack

func (d *TCPDialer) DialDualStack(addr string) (net.Conn, error)

func (*TCPDialer) DialDualStackTimeout

func (d *TCPDialer) DialDualStackTimeout(addr string, timeout time.Duration) (net.Conn, error)

func (*TCPDialer) DialTimeout

func (d *TCPDialer) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)

type Version

type Version struct {
	Major int
	Minor int
}

func (*Version) String

func (v *Version) String() string

Jump to

Keyboard shortcuts

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