upstream

package
v0.0.0-...-2c721bc Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUpstreamShouldRetry = errors.New("upstream failed")
)

Functions

This section is empty.

Types

type AzureOpenAIUpstream

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

func NewAzureOpenAIUpstream

func NewAzureOpenAIUpstream(server, key, apiVersion string, dialer proxy.Dialer) (*AzureOpenAIUpstream, error)

func (*AzureOpenAIUpstream) Serve

func (target *AzureOpenAIUpstream) Serve(w http.ResponseWriter, r *http.Request, errorHandler func(w http.ResponseWriter, r *http.Request, err error))

type Handler

type Handler interface {
	Serve(w http.ResponseWriter, r *http.Request, errorHandler func(w http.ResponseWriter, r *http.Request, err error))
}

type Policy

type Policy string
const (
	RandomPolicy     Policy = "random"
	RoundRobinPolicy Policy = "round_robin"
	WeightPolicy     Policy = "weight"
)

type ResponseError

type ResponseError struct {
	Err  error
	Resp *http.Response
}

func (ResponseError) Error

func (r ResponseError) Error() string

type TransparentUpstream

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

func NewTransparentUpstream

func NewTransparentUpstream(server string, key string, dialer proxy.Dialer) (*TransparentUpstream, error)

func (*TransparentUpstream) Serve

func (target *TransparentUpstream) Serve(w http.ResponseWriter, r *http.Request, errorHandler func(w http.ResponseWriter, r *http.Request, err error))

type Upstream

type Upstream struct {
	Rule        config.Rule
	Index       int
	Handler     Handler
	ServerIndex int
	KeyIndex    int
}

func (*Upstream) MaskedKey

func (u *Upstream) MaskedKey() string

func (*Upstream) MaskedServer

func (u *Upstream) MaskedServer() string

func (*Upstream) Name

func (u *Upstream) Name() string

type Upstreams

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

func BuildUpstreamsFromRules

func BuildUpstreamsFromRules(policy Policy, rules config.Rules, err error, dialer proxy.Dialer) (map[string]*Upstreams, *Upstreams, error)

func NewUpstreams

func NewUpstreams(policy Policy) *Upstreams

func (*Upstreams) Len

func (u *Upstreams) Len() int

func (*Upstreams) Next

func (u *Upstreams) Next(excludeIndex ...int) (*Upstream, int)

func (*Upstreams) Print

func (u *Upstreams) Print()

Jump to

Keyboard shortcuts

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