proxy

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttemptsOrRetry

type AttemptsOrRetry int

Load Balancer data structures...

const (
	ATTEMPTS AttemptsOrRetry = iota
	RETRY
)

type Backend

type Backend struct {
	URL   *url.URL
	Alive bool

	ReverseProxy *httputil.ReverseProxy
	// 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 Endpoint

type Endpoint struct {
	PathEndpoint  string `mapstructure:"path_endpoints"`
	PathToProxy   string `mapstructure:"path_proxy"`
	PathProtected bool   `mapstructure:"path_protected"`
}

Enpoint struct for enpoint object

type ProxyEndpoint

type ProxyEndpoint struct {
	Name      string     `mapstructure:"name"`
	HostURI   string     `mapstructure:"host_uri"`
	Endpoints []Endpoint `mapstructure:"endpoints"`
}

ProxyEndpoint struct for all enpoints

type ProxyRepository

type ProxyRepository interface {
	SaveKEY(string, string, string) error
	GetKEY(string, string) (string, error)
}

ProxyRepository interface

type ProxyRepositoryStorage

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

ProxyRepositoryStorage struct repository storage

func NewProxyRepository

func NewProxyRepository(clients ...interface{}) ProxyRepositoryStorage

NewProxyRepository return a new ProxyRepositoryStorage with a client `*badger.DB`

func (ProxyRepositoryStorage) GetKEY

func (r ProxyRepositoryStorage) GetKEY(engine, key string) (string, error)

GetKEY get key from the database

func (ProxyRepositoryStorage) SaveKEY

func (r ProxyRepositoryStorage) SaveKEY(engine, key, apikey string) error

SaveKEY save a key on the database

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) 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) 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