client

package
v4.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TargetHostMatches

func TargetHostMatches(target BalancerTarget, hosts string) bool

TargetHostMatches checks target.Address host against the passed string. hosts string is a pipe-separated list of hostname or IPs.

func TargetPIDMatches

func TargetPIDMatches(target BalancerTarget) bool

TargetPIDMatches is a generic matcher for PID

Types

type BalancerOption

type BalancerOption func(o *BalancerOptions)

func WithPriorityToLocal

func WithPriorityToLocal() BalancerOption

WithPriorityToLocal provides a BalancerOption to prioritize connections to local host.

func WithPriorityToProcess

func WithPriorityToProcess() BalancerOption

WithPriorityToProcess is mainly for testing purpopse, to prioritize connections to current process.

func WithRestrictToLocal

func WithRestrictToLocal() BalancerOption

WithRestrictToLocal provides a BalancerOption to forbid connection to hosts other than local.

func WithRestrictToProcess

func WithRestrictToProcess() BalancerOption

WithRestrictToProcess is mainly for testing purpose, forbidding connection to other processes

type BalancerOptions

type BalancerOptions struct {
	// Filters is a list of filters that will reduce the possible list of targets
	Filters []BalancerTargetFilter
	// Priority is a list of filters that will be tested first. If no target match, the load balancer
	// continues to the non-matching values
	Priority []BalancerTargetFilter
}

BalancerOptions holds internal load balancer strategies

type BalancerTarget

type BalancerTarget interface {
	// Address must return the target address. It can include a port
	Address() string
	// Attributes returns a set of grpc.Attributes
	Attributes() *attributes.Attributes
}

BalancerTarget is a load balancer target providing its own internal info

type BalancerTargetFilter

type BalancerTargetFilter func(BalancerTarget) bool

BalancerTargetFilter is a generic signature for matching a BalancerTarget against specific condition.

type ClientConfig

type ClientConfig struct {
	LBStrategies []*LBStrategy `json:"loadBalancingStrategies,omitempty"`
}

ClientConfig holds configuration for a specific client (http or grpc)

func (ClientConfig) LBOptions

func (c ClientConfig) LBOptions() (oo []BalancerOption)

LBOptions converts LBStrategies to a slice of BalancerOption

type ClusterConfig

type ClusterConfig struct {
	Clients map[string]ClientConfig `json:"clients"`
}

ClusterConfig holds configuration for cluster

func (ClusterConfig) GetClientConfig

func (c ClusterConfig) GetClientConfig(name string) ClientConfig

GetClientConfig returns ClientConfig for a specific client (either grpc or http)

type LBStrategy

type LBStrategy struct {
	Name   string                 `json:"name"`
	Config map[string]interface{} `json:"config,omitempty"`
}

LBStrategy holds LoadBalancer strategies for a given client

type ResolverCallback

type ResolverCallback interface {
	Add(UpdateStateCallback)
	Stop()
}

ResolverCallback is a generic watcher for registry, that rebuilds the list of available targets and calls the passed callbacks on change event. It is used by both grpc and http balancers.

func NewResolverCallback

func NewResolverCallback(reg registry.Registry) (ResolverCallback, error)

NewResolverCallback creates a new ResolverCallback watching the passed registry.Registry

type ServerAttributes

type ServerAttributes struct {
	Name               string
	Addresses          []string
	Services           []string
	Endpoints          []string
	BalancerAttributes *attributes.Attributes
}

type UpdateStateCallback

type UpdateStateCallback func(map[string]*ServerAttributes) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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