Documentation ¶
Index ¶
- Constants
- func GetAttemptsFromContext(r *http.Request) int
- func GetRetryFromContext(r *http.Request) int
- type Backend
- type Server
- type ServerPool
- func (s *ServerPool) AddBackend(backend *Backend)
- func (s *ServerPool) Destroy()
- func (s *ServerPool) GetNextPeer() *Backend
- func (s *ServerPool) HealthCheck()
- func (s *ServerPool) IsClose() bool
- func (s *ServerPool) MarkBackendStatus(backendUrl *url.URL, alive bool)
- func (s *ServerPool) NextIndex() int
Constants ¶
View Source
const ( Attempts int = iota Retry )
Variables ¶
This section is empty.
Functions ¶
func GetAttemptsFromContext ¶
GetAttemptsFromContext returns the attempts for request
func GetRetryFromContext ¶
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
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) 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
Click to show internal directories.
Click to hide internal directories.