ptoclient

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 11 Imported by: 0

README

go-PTOC

Go Predictive Timeout Client

Build: ./build

Documentation

Index

Constants

View Source
const (
	ClientDefaultTimeout         = time.Duration(1000) * time.Millisecond // Sec
	ClientTimeoutIncInterval     = time.Duration(2000) * time.Millisecond // Sec
	ClientTimeoutReportCount     = 5                                      // Count
	ClientWindowDefaultThreshold = 70                                     // indicates % of timeout reports when window is full
	ClientWindowDefaultSize      = 5                                      // Window Size
)
View Source
const (
	DNSLookup        = "DNSLookup"
	TCPConnection    = "TCPConnection"
	TLSHandshake     = "TLSHandshake"
	ServerProcessing = "ServerProcessing"
	ContentTransfer  = "ContentTransfer"
	Total            = "Total"
)
View Source
const (
	DNS_TIMEOUT = "dial tcp"
	TLS_TIMEOUT = "TLS handshake timeout"
	REQ_TIMEOUT = "Client.Timeout exceeded while awaiting headers"
)
View Source
const (
	INVALID       = -1
	DNS_TIMEOUT_I = 1
	TLS_TIMEOUT_I = 2
	REQ_TIMEOUT_I = 4
)
View Source
const PERCENT = "%"

Variables

Functions

func IsConnTimeoutErr

func IsConnTimeoutErr(err error) bool

func WithConsTimeoutEnabled

func WithConsTimeoutEnabled(val bool) func(*HTTPClient) error

func WithCustomTransport

func WithCustomTransport(dialtimeout, tlstimeout int) func(*HTTPClient) error

func WithDefaultTimeout

func WithDefaultTimeout(val int) func(*HTTPClient) error

func WithMaxDefaultTimeout

func WithMaxDefaultTimeout(val int) func(*HTTPClient) error

func WithSlidingWindowEnabled

func WithSlidingWindowEnabled(val bool) func(*HTTPClient) error

func WithSlidingWindowSize

func WithSlidingWindowSize(val int) func(*HTTPClient) error

func WithSlidingWindowThreshold

func WithSlidingWindowThreshold(val int) func(*HTTPClient) error

func WithTimeoutIncInterval

func WithTimeoutIncInterval(val int) func(*HTTPClient) error

func WithTimeoutReportCount

func WithTimeoutReportCount(val int) func(*HTTPClient) error

func WithZaplogger

func WithZaplogger(log *zap.SugaredLogger) func(*HTTPClient) error

Types

type HTTPClient

type HTTPClient struct {
	*http.Client

	Dialer func(ctx context.Context, network string, address string) (net.Conn, error)
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(h *http.Client, opts ...Option) (*HTTPClient, error)

func (*HTTPClient) Do

func (h *HTTPClient) Do(req *http.Request) (*http.Response, error)

func (*HTTPClient) NotifySlidingWindow

func (h *HTTPClient) NotifySlidingWindow(stats *HTTPStats)

type HTTPStats

type HTTPStats struct {
	DNSLookup        int    `json:"DNSLookup"`
	TCPConnection    int    `json:"TCPConnection"`
	TLSHandshake     int    `json:"TLSHandshake"`
	ServerProcessing int    `json:"ServerProcessing"`
	ContentTransfer  int    `json:"ContentTransfer"`
	Total            int    `json:"Total"`
	URL              string `json:"URL"`
	ReqTimeout       int    `json:"ClientTimeout"`
	DnsTimeout       int    `json:"DNSTimeout"`
	TlsTimeout       int    `json:"TLSTimeout"`
	TimeoutReason    int    `json:"TimeoutReason"`
	Message          string `json:"message"`
}

type Option

type Option func(*HTTPClient) error

type Window

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

func (*Window) AddEle

func (w *Window) AddEle(stat *HTTPStats)

func (*Window) GetTimeoutThreshold

func (w *Window) GetTimeoutThreshold() int

func (*Window) Print

func (w *Window) Print(p bool)

func (*Window) RemoveEle

func (w *Window) RemoveEle()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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