upstream

package
v0.0.0-...-b9f95b1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2017 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package upstream upstream backends

Index

Constants

View Source
const (
	HT_REMOTE_IP = iota + 1
	HT_REMOTE_PORT
	HT_NONE
)
View Source
const (
	TT_STATIC = iota + 1
)

Variables

This section is empty.

Functions

func AutoUpdatePeer

func AutoUpdatePeer(us *Upstream, seconds int)

AutoUpdatePeer is a helper function that will update the list of dynamic upstream peers at a regular rate defined by the parameter seconds.

Types

type IDynamicUpstreamSource

type IDynamicUpstreamSource interface {
	UpdatePeers() ([]string, error)
}

type Upstream

type Upstream struct {
	Config     *config.Upstream
	Targets    []string
	TargetType uint8
	RRcounter  uint
	IsDynamic  bool

	HashType  uint8
	HashCache *cache.CacheManager

	DynamicSource     IDynamicUpstreamSource
	DynamicSourceLock sync.Mutex
}

func MustNewUpstream

func MustNewUpstream(cfg *config.Upstream) *Upstream

MustNewUpstream does the same thing as NewUpstream and will panic if the creation fails

func NewUpstream

func NewUpstream(cfg *config.Upstream) (*Upstream, error)

NewUpstream parses an upstream configuration block and creates an Upstream object

func (*Upstream) GetPeer

func (m *Upstream) GetPeer(hash uint32) (*string, error)

GetPeer will fetch a peer either from the cache or the peers list upon request

func (*Upstream) GetRRPeer

func (m *Upstream) GetRRPeer() (*string, error)

GetRRPeer will get a peer from the peers list with a round-robin behavior

func (*Upstream) UpdateDynamicPeers

func (m *Upstream) UpdateDynamicPeers()

UpdateDynamicPeers will update the peers of a dynamic upstream

Jump to

Keyboard shortcuts

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