tcp

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConn

func CheckConn(addr string, timeout time.Duration) error

CheckConn checks if addr is connectable

Types

type Checker

type Checker struct {
	Options // inherited options
	// contains filtered or unexported fields
}

Checker checks if the addresses are connectable

func NewChecker

func NewChecker(opts ...Option) *Checker

NewChecker creates a tcp checker

func (*Checker) Add

func (c *Checker) Add(addr string) error

Add adds a new addr to the checking pool, valid addr format is host:port

func (*Checker) IsDown

func (c *Checker) IsDown(addr string) bool

IsDown returns true if error count exceeds threshold

func (*Checker) Remove

func (c *Checker) Remove(addr string)

Remove removes the addr from the checking pool

type Option

type Option func(*Options)

Option is for setting options

func WithInterval

func WithInterval(interval time.Duration) Option

WithInterval sets check interval

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets logger

func WithMaxErrorCount

func WithMaxErrorCount(maxErrorCount int) Option

WithMaxErrorCount sets maximum error count

func WithSuccessiveOK

func WithSuccessiveOK(SuccessiveOK int) Option

WithSuccessiveOK sets successive check passing count

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets check timeout

type Options

type Options struct {
	Logger        log.Logger
	Timeout       time.Duration
	Interval      time.Duration
	MaxErrorCount int
	SuccessiveOK  int
}

Options is tcp checker options

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions creates options with defaults

Jump to

Keyboard shortcuts

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