upstream

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBackendIsDown                = errors.New("backend is down")
	ErrBackendIsTooBusy             = errors.New("backend is too busy")
	ErrNotHealthyStatusCode         = errors.New("bad status code")
	ErrRefreshUpstreamBadStatusCode = errors.New("invalid upstream status code")
)

Functions

func ChangePolicy added in v1.6.0

func ChangePolicy(policy Policy) error

Types

type Backend

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

func NewBackend

func NewBackend(ctx context.Context, cfg *config.Backend, traceCfg *config.Observability) *Backend

NewBackend creates a new instance of Backend.

func (*Backend) IsHealthy

func (b *Backend) IsHealthy() error

func (*Backend) ProxyRequest added in v1.6.0

func (b *Backend) ProxyRequest(ctx *fasthttp.RequestCtx, traceCtx context.Context) (*fasthttp.Response, Releaser, error)

func (*Backend) Refresh added in v1.6.0

func (b *Backend) Refresh(entry *model.Entry) error

func (*Backend) Request added in v1.6.0

func (b *Backend) Request(nilableCtx *fasthttp.RequestCtx, rule *config.Rule, queries, headers [][2][]byte, traceCtx context.Context,
) (*fasthttp.Response, Releaser, error)

func (*Backend) SetHealth added in v1.6.0

func (b *Backend) SetHealth(up bool)

type Policy added in v1.6.0

type Policy string
const (
	Deny  Policy = "deny"
	Await Policy = "await"
)

func ActualPolicy added in v1.6.0

func ActualPolicy() Policy

func (Policy) Uint64 added in v1.7.0

func (p Policy) Uint64() uint64

type Releaser added in v1.6.0

type Releaser func(*fasthttp.Response)

type RequestReleaser added in v1.6.0

type RequestReleaser func(request *fasthttp.Request)

type Upstream

type Upstream interface {
	Request(nilableCtx *fasthttp.RequestCtx, rule *config.Rule, queries, headers [][2][]byte, traceCtx context.Context) (*fasthttp.Response, Releaser, error)
	ProxyRequest(ctx *fasthttp.RequestCtx, traceCtx context.Context) (*fasthttp.Response, Releaser, error)
	Refresh(entry *model.Entry) error
	IsHealthy() error
}

Upstream defines the interface for external backends. Note: you need provide just one argument of inCtx or inReq.

Jump to

Keyboard shortcuts

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