proxyfunctions

package
v0.0.0-...-23d10c9 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path string
	Host string
}

Config This is the config of a server. It has a Path and a Host.

type Serverlist

type Serverlist struct {
	Servers   map[string]*server
	Tqueries  list.List
	Prefix    string
	Mux       sync.Mutex
	Informers []chan string //maybe use a list.List if deletion of channels gets important
	Stop      chan struct{}
	// contains filtered or unexported fields
}

Serverlist The Serverlist includes the backend servers in a slice and the queries of the clients (Tqueries). All new connections will lead to new Tqueries. When there are free resources available, a ticket will be generated and the Tqueries will be removed from the list.

func NewServerlist

func NewServerlist(prefix string, dns bool) *Serverlist

NewServerlist Creates a new Serverlist, needs a prefix (app label).

func (*Serverlist) AddInformerChannel

func (list *Serverlist) AddInformerChannel() chan string

AddInformerChannel This function allows to inform external functions about new and removed tickets. It informs with "new ticket", "delete ticket", "adding server", "deleting server".

func (*Serverlist) AddServer

func (list *Serverlist) AddServer(name string, maxtickets int, Config Config) error

AddServer This function adds a new server to the serverlist. It requieres a name, the maximal number of tickets that can be handeled by this server and the Config

func (*Serverlist) ChangeAllMaxTickets

func (list *Serverlist) ChangeAllMaxTickets(newMaxTickets int)

ChangeAllMaxTickets This function changes the MaxTickets on all servers

func (*Serverlist) GetAvailableTickets

func (list *Serverlist) GetAvailableTickets() int

GetAvailableTickets This function returns the number of all available slots on all known and active servers.

func (*Serverlist) GetTickets

func (list *Serverlist) GetTickets() int

GetTickets This function returns the number of occupied tickets on all known servers.

func (*Serverlist) MainHandler

func (list *Serverlist) MainHandler(w http.ResponseWriter, r *http.Request)

MainHandler This function provides the toplevel handler for the proxy requests It uses CallServer to handle all connection details.

func (*Serverlist) ServeHome

func (list *Serverlist) ServeHome(w http.ResponseWriter, r *http.Request)

ServeHome This function serves the home page.

func (*Serverlist) ServeWs

func (list *Serverlist) ServeWs(w http.ResponseWriter, r *http.Request)

ServeWs This handler serves the WebSocket connection to acquire the cookie and the Ticket. The delivered home page will wait until a cookie and a backend is transferred. This function also handels the initial creation of Ticket by calling querrymanager.

func (*Serverlist) SetServerDeletion

func (list *Serverlist) SetServerDeletion(name string) error

SetServerDeletion This function marks a server to be deleted.

func (*Serverlist) TicketWatchdog

func (list *Serverlist) TicketWatchdog()

TicketWatchdog This function checks if tickets are still valid (updated in specified time by a HTTP connection). If the ticket was not updated in time, it will be removed from the server.

Jump to

Keyboard shortcuts

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