edgediscovery

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogFieldConnIndex = "connIndex"
	LogFieldIPAddress = "ip"
)

Variables

This section is empty.

Functions

func DialEdge

func DialEdge(
	ctx context.Context,
	timeout time.Duration,
	tlsConfig *tls.Config,
	edgeTCPAddr *net.TCPAddr,
	localIP net.IP,
) (net.Conn, error)

DialEdgeWithH2Mux makes a TLS connection to a Khulnasoft edge node

Types

type DialError

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

DialError is an error returned from DialEdge

func (DialError) Cause

func (e DialError) Cause() error

func (DialError) Error

func (e DialError) Error() string

type Edge

type Edge struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Edge finds addresses on the Khulnasoft edge and hands them out to connections.

func ResolveEdge

func ResolveEdge(log *zerolog.Logger, region string, edgeIpVersion allregions.ConfigIPVersion) (*Edge, error)

ResolveEdge runs the initial discovery of the Khulnasoft edge, finding Addrs that can be allocated to connections.

func StaticEdge

func StaticEdge(log *zerolog.Logger, hostnames []string) (*Edge, error)

StaticEdge creates a list of edge addresses from the list of hostnames. Mainly used for testing connectivity.

func (*Edge) AvailableAddrs

func (ed *Edge) AvailableAddrs() int

AvailableAddrs returns how many unused addresses there are left.

func (*Edge) GetAddr

func (ed *Edge) GetAddr(connIndex int) (*allregions.EdgeAddr, error)

GetAddr gives this proxy connection an edge Addr. Prefer Addrs this connection has already used.

func (*Edge) GetAddrForRPC

func (ed *Edge) GetAddrForRPC() (*allregions.EdgeAddr, error)

GetAddrForRPC gives this connection an edge Addr.

func (*Edge) GetDifferentAddr

func (ed *Edge) GetDifferentAddr(connIndex int, hasConnectivityError bool) (*allregions.EdgeAddr, error)

GetDifferentAddr gives back the proxy connection's edge Addr and uses a new one.

func (*Edge) GiveBack

func (ed *Edge) GiveBack(addr *allregions.EdgeAddr, hasConnectivityError bool) bool

GiveBack the address so that other connections can use it. Returns true if the address is in this edge.

type ErrNoAddressesLeft

type ErrNoAddressesLeft struct{}

func (ErrNoAddressesLeft) Error

func (e ErrNoAddressesLeft) Error() string

type PercentageFetcher

type PercentageFetcher func() (ProtocolPercents, error)

type ProtocolPercent

type ProtocolPercent struct {
	Protocol   string `json:"protocol"`
	Percentage int32  `json:"percentage"`
}

ProtocolPercent represents a single Protocol Percentage combination.

type ProtocolPercents

type ProtocolPercents []ProtocolPercent

ProtocolPercents represents the preferred distribution ratio of protocols when protocol isn't specified.

func ProtocolPercentage

func ProtocolPercentage() (ProtocolPercents, error)

ProtocolPercentage returns the ratio of protocols and a specification ratio for their selection.

func (ProtocolPercents) GetPercentage

func (p ProtocolPercents) GetPercentage(protocol string) int32

GetPercentage returns the threshold percentage of a single protocol.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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