proxy

package
v0.0.0-...-390f9a4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Attempts int = iota
	Retry
)

Variables

This section is empty.

Functions

func GetAttemptsFromContext

func GetAttemptsFromContext(r *http.Request) int

GetAttemptsFromContext returns the attempts for request

func GetRetryFromContext

func GetRetryFromContext(r *http.Request) int

GetRetryFromContext returns the retries for request

Types

type Backend

type Backend struct {
	URL   *url.URL
	Alive bool

	ReverseProxy   *httputil.ReverseProxy
	HealthCheckURL string
	// contains filtered or unexported fields
}

Backend holds the data about a server

func (*Backend) IsAlive

func (b *Backend) IsAlive() (alive bool)

IsAlive returns true when backend is alive

func (*Backend) SetAlive

func (b *Backend) SetAlive(alive bool)

SetAlive for this backend

type Server

type Server struct {
	BackendList []string
	// contains filtered or unexported fields
}

func NewProxyServer

func NewProxyServer(llmProvider provider.LLMProvider) *Server

func (*Server) ReloadBackend

func (s *Server) ReloadBackend()

func (*Server) Run

func (s *Server) Run(port int)

func (*Server) SyncBackend

func (s *Server) SyncBackend()

SyncBackend Scheduled synchronization of backend

type ServerPool

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

ServerPool holds information about reachable backends

func (*ServerPool) AddBackend

func (s *ServerPool) AddBackend(backend *Backend)

AddBackend to the server pool

func (*ServerPool) Destroy

func (s *ServerPool) Destroy()

func (*ServerPool) GetNextPeer

func (s *ServerPool) GetNextPeer() *Backend

GetNextPeer returns next active peer to take a connection

func (*ServerPool) HealthCheck

func (s *ServerPool) HealthCheck()

HealthCheck pings the backends and update the status

func (*ServerPool) IsClose

func (s *ServerPool) IsClose() bool

func (*ServerPool) MarkBackendStatus

func (s *ServerPool) MarkBackendStatus(backendUrl *url.URL, alive bool)

MarkBackendStatus changes a status of a backend

func (*ServerPool) NextIndex

func (s *ServerPool) NextIndex() int

NextIndex atomically increase the counter and return an index

Jump to

Keyboard shortcuts

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