upstream

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotHealthyStatusCode         = errors.New("bad status code")
	ErrRefreshUpstreamBadStatusCode = errors.New("invalid upstream status code")
)
View Source
var (
	ErrNoBackendsConfigured = errors.New("cluster: no backends configured")
	ErrNoRatesConfigured    = errors.New("cluster: no backend rates configured")
	ErrAllBackendsAreBusy   = errors.New("cluster: all backends are busy")
	ErrAllBackendsAreGone   = errors.New("cluster: all backends are gone")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	ID() string
	Name() string
	IsHealthy() error
	Cfg() *config.Backend
	Fetch(rule *config.Rule, inCtx *fasthttp.RequestCtx, inReq *fasthttp.Request) (
		outReq *fasthttp.Request, outResp *fasthttp.Response,
		releaser func(*fasthttp.Request, *fasthttp.Response), err error,
	)
}

type BackendCluster

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

func NewBackendCluster

func NewBackendCluster(ctx context.Context, cfg config.Config) (*BackendCluster, error)

func (*BackendCluster) Fetch

func (c *BackendCluster) Fetch(
	rule *config.Rule, inCtx *fasthttp.RequestCtx, inReq *fasthttp.Request,
) (outReq *fasthttp.Request, outResp *fasthttp.Response, releaser func(*fasthttp.Request, *fasthttp.Response), err error)

Fetch - proxy method which takes first allowed backend and do request. Errors:

  1. ErrAllBackendsAreBusy
  2. ErrAllBackendsAreGone

func (*BackendCluster) Refresh added in v1.4.4

func (c *BackendCluster) Refresh(entry *model.Entry) error

type BackendNode

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

func NewBackend

func NewBackend(cfg *config.Backend) *BackendNode

NewBackend creates a new instance of BackendNode.

func (*BackendNode) Cfg

func (b *BackendNode) Cfg() *config.Backend

func (*BackendNode) Fetch

func (b *BackendNode) Fetch(rule *config.Rule, inCtx *fasthttp.RequestCtx, inReq *fasthttp.Request) (
	outReq *fasthttp.Request, outResp *fasthttp.Response, releaser func(*fasthttp.Request, *fasthttp.Response), err error,
)

Fetch actually performs the HTTP request to backend and parses the response. Note: that rule is optional and if not provided response will not delete unavailable headers for store. Also remember that you need provide only one argument: inCtx or inReq.

func (*BackendNode) ID

func (b *BackendNode) ID() string

func (*BackendNode) IsHealthy

func (b *BackendNode) IsHealthy() error

func (*BackendNode) Name

func (b *BackendNode) Name() string

func (*BackendNode) Refresh added in v1.4.4

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

type Upstream

type Upstream interface {
	Fetch(rule *config.Rule, inCtx *fasthttp.RequestCtx, inReq *fasthttp.Request) (
		outReq *fasthttp.Request, outResp *fasthttp.Response, releaser func(*fasthttp.Request, *fasthttp.Response), err error,
	)
	Refresh(entry *model.Entry) 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