proxy

package
v0.0.0-...-08b9edc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package proxy provides a TCP reverse proxy. Unlike normal reverse proxy, the upstream is intentionally fixed. A new upstream will be selected if the current upstream is down.

Index

Constants

View Source
const (
	DefaultUpstreamProbeInterval = 2 * time.Second
	DefaultDialTimeout           = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	KindTag               string
	UpstreamProbeInterval time.Duration
	DialTimeout           time.Duration
}

type Proxy

type Proxy struct {
	nocopy.NoCopy
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Proxy, error)

func (*Proxy) Close

func (p *Proxy) Close()

Close stops any running loops and stops the listener. This function is concurrent-safe.

func (*Proxy) HasActiveUpstream

func (p *Proxy) HasActiveUpstream() bool

HasActiveUpstream returns whether there is an active upstream.

func (*Proxy) Port

func (p *Proxy) Port() int

Port returns the actual listening port.

func (*Proxy) SetUpstreams

func (p *Proxy) SetUpstreams(addresses []string)

SetUpstreams sets the upstream address list. This function is concurrent-safe.

Jump to

Keyboard shortcuts

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