lblhttpclient

package
v1.4.10 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConnectTimeout      time.Duration = time.Second * 3
	DefaultWaitResponseTimeout time.Duration = time.Second

	JsonExpGroupTarget     string = "LB_TARGET"
	JsonExpVarTargetServer string = "$LB_TARGET_SERVER"
	JsonExpUrlPath         string = "__PATH__"
	JsonExpObjectURI       string = "$REQUEST_URI"
)

Variables

View Source
var (
	ErrorAliasExists     = errors.New("backend's alias of load balance client exists")
	ErrorAliasNotExist   = errors.New("backend's alias not found")
	ErrorJsonExpNotFound = errors.New("jsonexp for target select not found")
	ErrorNoServerDefined = errors.New("no backend server defined")
)

Functions

func DefaultHealthCheck

func DefaultHealthCheck(req *http.Request, resp *http.Response, err error) bool

Types

type HealthCheck

type HealthCheck func(req *http.Request, resp *http.Response, err error) bool

type LblHttpClient

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

func NewLoadBalanceClient

func NewLoadBalanceClient(method LoadBalanceMethod, maxIdleConnectionsPerServer int, methodUrlParamKey string, connTimeout, waitResponseTimeout time.Duration) *LblHttpClient

func (*LblHttpClient) AddBackend

func (m *LblHttpClient) AddBackend(addr string, alias string, healthCheck HealthCheck) error

func (*LblHttpClient) DoRequest

func (m *LblHttpClient) DoRequest(clientIp string, request *http.Request) (*http.Response, error)

func (*LblHttpClient) RemoveBackend

func (m *LblHttpClient) RemoveBackend(alias string) error

func (*LblHttpClient) SetJsonExp

func (m *LblHttpClient) SetJsonExp(jsonExpJson []byte) error

type LoadBalanceMethod

type LoadBalanceMethod uint32
const (
	MethodRoundrobin LoadBalanceMethod = iota
	MethodRandom
	MethodMinPending
	MethodIpHash
	MethodUrlParam
	MethodJsonExp // very powerful
)

type UrlValuesForJsonExp

type UrlValuesForJsonExp struct {
	Path      string
	UrlValues url.Values
}

func (*UrlValuesForJsonExp) GetPropertyValue

func (m *UrlValuesForJsonExp) GetPropertyValue(property string, context jsonexp.Context) interface{}

func (*UrlValuesForJsonExp) SetPropertyValue

func (m *UrlValuesForJsonExp) SetPropertyValue(property string, value interface{}, context jsonexp.Context)

implements jsonexp.Object

Jump to

Keyboard shortcuts

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