util

package
v2.0.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinAddrFormat min addr format
	MinAddrFormat = "000000000000000000000"
	// MaxAddrFormat max addr format
	MaxAddrFormat = "255.255.255.255:99999"
)

Variables

This section is empty.

Functions

func GetAddrFormat

func GetAddrFormat(addr string) string

GetAddrFormat returns addr format for sort, padding left by 0

func GetAddrNextFormat

func GetAddrNextFormat(addr string) string

GetAddrNextFormat returns next addr format for sort, padding left by 0

Types

type Analysis

type Analysis struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Analysis analysis struct

func NewAnalysis

func NewAnalysis(tw *goetty.TimeoutWheel) *Analysis

NewAnalysis returns a Analysis

func (*Analysis) AddTarget

func (a *Analysis) AddTarget(key uint64, interval time.Duration)

AddTarget add analysis point on a key

func (*Analysis) Failure

func (a *Analysis) Failure(key uint64)

Failure incr failure count

func (*Analysis) GetContinuousFailureCount

func (a *Analysis) GetContinuousFailureCount(server uint64) int

GetContinuousFailureCount return Continuous failure request count in spec secs

func (*Analysis) GetQPS

func (a *Analysis) GetQPS(server uint64, interval time.Duration) int

GetQPS return qps in spec duration

func (*Analysis) GetRecentlyAvg

func (a *Analysis) GetRecentlyAvg(server uint64, interval time.Duration) int

GetRecentlyAvg return avg latency in spec secs

func (*Analysis) GetRecentlyMax

func (a *Analysis) GetRecentlyMax(server uint64, interval time.Duration) int

GetRecentlyMax return max latency in spec secs

func (*Analysis) GetRecentlyMin

func (a *Analysis) GetRecentlyMin(server uint64, interval time.Duration) int

GetRecentlyMin return min latency in spec duration

func (*Analysis) GetRecentlyRejectCount

func (a *Analysis) GetRecentlyRejectCount(server uint64, interval time.Duration) int

GetRecentlyRejectCount return reject count in spec duration

func (*Analysis) GetRecentlyRequestCount

func (a *Analysis) GetRecentlyRequestCount(server uint64, interval time.Duration) int

GetRecentlyRequestCount return the server request count in spec duration

func (*Analysis) GetRecentlyRequestFailureCount

func (a *Analysis) GetRecentlyRequestFailureCount(server uint64, interval time.Duration) int

GetRecentlyRequestFailureCount return failure request count in spec duration

func (*Analysis) GetRecentlyRequestSuccessedCount

func (a *Analysis) GetRecentlyRequestSuccessedCount(server uint64, interval time.Duration) int

GetRecentlyRequestSuccessedCount return successed request count in spec secs

func (*Analysis) Reject

func (a *Analysis) Reject(key uint64)

Reject incr reject count

func (*Analysis) RemoveTarget

func (a *Analysis) RemoveTarget(key uint64)

RemoveTarget remove analysis point on a key

func (*Analysis) Request

func (a *Analysis) Request(key uint64)

Request incr request count

func (*Analysis) Response

func (a *Analysis) Response(key uint64, cost int64)

Response incr successed count

type FastHTTPClient

type FastHTTPClient struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

FastHTTPClient fast http client

func NewFastHTTPClient

func NewFastHTTPClient() *FastHTTPClient

NewFastHTTPClient create FastHTTPClient instance

func NewFastHTTPClientOption

func NewFastHTTPClientOption(defaultOption *HTTPOption) *FastHTTPClient

NewFastHTTPClientOption create FastHTTPClient instance with default option

func (*FastHTTPClient) Do

func (c *FastHTTPClient) Do(req *fasthttp.Request, addr string, option *HTTPOption) (*fasthttp.Response, error)

Do do a http request

type HTTPOption

type HTTPOption struct {
	// Maximum number of connections which may be established to server
	MaxConns int
	// MaxConnDuration Keep-alive connections are closed after this duration.
	MaxConnDuration time.Duration
	// MaxIdleConnDuration Idle keep-alive connections are closed after this duration.
	MaxIdleConnDuration time.Duration
	// ReadBufferSize Per-connection buffer size for responses' reading.
	ReadBufferSize int
	// WriteBufferSize Per-connection buffer size for requests' writing.
	WriteBufferSize int
	// ReadTimeout Maximum duration for full response reading (including body).
	ReadTimeout time.Duration
	// WriteTimeout Maximum duration for full request writing (including body).
	WriteTimeout time.Duration
	// MaxResponseBodySize Maximum response body size.
	MaxResponseBodySize int
}

HTTPOption http client option

func DefaultHTTPOption

func DefaultHTTPOption() *HTTPOption

DefaultHTTPOption returns a HTTP Option

type Recently

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

Recently recently point data

Jump to

Keyboard shortcuts

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