resource

package
v0.0.0-...-39bbb24 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoHostAvailable when the backend don't have hosts
	ErrNoHostAvailable = errors.New("No host available")
)

Functions

This section is empty.

Types

type CustomDialer

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

CustomDialer implements a roundrobin connection pool based on the resources in the backend. Could be IP or hosts. If is hosts it will refresh the DNS resolution every 5s and will all the returned IPs in the slice of hosts

func (*CustomDialer) Addr

func (cd *CustomDialer) Addr() string

func (*CustomDialer) DialContext

func (cd *CustomDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext will use one IP from the resources using the round-robin and call to the original net.DialContext

func (*CustomDialer) DialTLSContext

func (cd *CustomDialer) DialTLSContext(ctx context.Context, network, address string) (net.Conn, error)

type HealthCheck

type HealthCheck struct {
	URL         string
	RespCode    int
	RespContent string
	Interval    string
	// contains filtered or unexported fields
}

type Resource

type Resource struct {
	Protocol string
	Host     string

	Transport   *http.Transport
	HealthCheck HealthCheck
	// contains filtered or unexported fields
}

func New

func New(p discoverlib.Plugin, host string, useTLS bool, Healthcheck HealthCheck) *Resource

func (*Resource) Before

func (r *Resource) Before(t time.Time) bool

func (*Resource) Close

func (r *Resource) Close()

func (*Resource) IsClose

func (r *Resource) IsClose() bool

func (*Resource) IsHealthy

func (r *Resource) IsHealthy() bool

func (*Resource) Update

func (r *Resource) Update()

Jump to

Keyboard shortcuts

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