proxy

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fnv

func Fnv(b []byte) uint32

func RegisterPolicy

func RegisterPolicy(name string, policy func() Policy)

Types

type Balance

type Balance struct {
	Name string `json:"name"`
}

type BodyHash

type BodyHash struct {
	Args []string `json:"args"`
	// contains filtered or unexported fields
}

BodyHash is a policy that selects hosts based on hashing the request args

func (*BodyHash) Init

func (r *BodyHash) Init() error

func (*BodyHash) Select

func (r *BodyHash) Select(pool HostPool, ctx *fasthttp.RequestCtx) *fasthttputil.Proxy

type First

type First struct{}

First is a policy that selects hosts based front active host

func (*First) Init

func (r *First) Init() error

func (*First) Select

func (r *First) Select(pool HostPool, ctx *fasthttp.RequestCtx) *fasthttputil.Proxy

type HostPool

type HostPool []*fasthttputil.Proxy

type IPHash

type IPHash struct{}

IPHash is a policy that selects hosts based on hashing the request ip

func (*IPHash) Init

func (r *IPHash) Init() error

func (*IPHash) Select

func (r *IPHash) Select(pool HostPool, ctx *fasthttp.RequestCtx) *fasthttputil.Proxy

type Policy

type Policy interface {
	Select(pool HostPool, ctx *fasthttp.RequestCtx) *fasthttputil.Proxy
	Init() error
}

type Proxy

type Proxy struct {
	Balance map[string]interface{} `json:"balance"`
	Targets []*fasthttputil.Target `json:"targets"`
	// contains filtered or unexported fields
}

func (*Proxy) Cron

func (p *Proxy) Cron()

func (*Proxy) Handler

func (p *Proxy) Handler() fasthttp.RequestHandler

func (*Proxy) Init

func (p *Proxy) Init(c *middleware.Config) (err error)

func (*Proxy) Process

func (*Proxy) UnInit

func (p *Proxy) UnInit()

type ProxyHeader

type ProxyHeader struct {
	Set map[string]string `json:"set"`
	Add map[string]string `json:"add"`
	Del []string          `json:"del"`
}

func (*ProxyHeader) Handler

func (p *ProxyHeader) Handler() fasthttp.RequestHandler

func (*ProxyHeader) Init

func (p *ProxyHeader) Init(c *middleware.Config) (err error)

func (*ProxyHeader) Process

func (*ProxyHeader) UnInit

func (p *ProxyHeader) UnInit()

type Random

type Random struct{}

Random is a policy that selects up hosts from a pool at random.

func (*Random) Init

func (r *Random) Init() error

func (*Random) Select

func (r *Random) Select(pool HostPool, ctx *fasthttp.RequestCtx) *fasthttputil.Proxy

Select selects an up host at random from the specified pool.

type Ratelimit

type Ratelimit struct {
	Methods  map[string]string `json:"methods"`
	Headers  map[string]string `json:"headers"`
	Args     map[string]string `json:"args"`
	Max      int               `json:"max"`
	Duration string            `json:"duration"`
	Timeout  string            `json:"timeout"`
	Message  struct {
		ContentType string `json:"content_type"`
		Message     string `json:"message"`
		StatusCode  string `json:"status_code"`
	} `json:"message"`
	// contains filtered or unexported fields
}

func (*Ratelimit) Handler

func (p *Ratelimit) Handler() fasthttp.RequestHandler

func (*Ratelimit) Init

func (p *Ratelimit) Init(c *middleware.Config) (err error)

func (*Ratelimit) Process

func (*Ratelimit) UnInit

func (p *Ratelimit) UnInit()

type RoundRobin

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

RoundRobin is a policy that selects hosts based on round robin ordering.

func (*RoundRobin) Init

func (r *RoundRobin) Init() error

func (*RoundRobin) Select

func (r *RoundRobin) Select(pool HostPool, ctx *fasthttp.RequestCtx) *fasthttputil.Proxy

Select selects an up host from the pool using a round robin ordering scheme.

Jump to

Keyboard shortcuts

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