core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2017 License: MPL-2.0 Imports: 4 Imported by: 8

Documentation

Overview

core centralizes the commonly used interfaces and structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backender

type Backender interface {
	Init() error
	// services
	GetServices() ([]Service, error)
	GetService(id string) (*Service, error)
	SetServices(services []Service) error
	SetService(service *Service) error
	DeleteService(id string) error
	// servers
	SetServers(svcId string, servers []Server) error
	SetServer(svcId string, server *Server) error
	DeleteServer(svcId, srvId string) error
	GetServer(svcId, srvId string) (*Server, error)
}

type CertBundle

type CertBundle struct {
	Cert string `json:"cert"`
	Key  string `json:"key"`
}

type Proxyable

type Proxyable interface {
	// routes
	SetRoute(route Route) error
	SetRoutes(routes []Route) error
	DeleteRoute(route Route) error
	GetRoutes() ([]Route, error)
	// certs
	SetCerts(certs []CertBundle) error
	SetCert(cert CertBundle) error
	DeleteCert(cert CertBundle) error
	GetCerts() ([]CertBundle, error)
}

type Route

type Route struct {
	// defines match characteristics
	SubDomain string `json:"subdomain"` // subdomain to match on - "admin"
	Domain    string `json:"domain"`    // domain to match on - "myapp.com"
	Path      string `json:"path"`      // route to match on - "/admin"
	// defines actions
	Targets []string `json:"targets"` // ips of servers - ["http://127.0.0.1:8080/app1","http://127.0.0.2"] (optional)
	FwdPath string   `json:"fwdpath"` // path to forward to targets - "/goadmin" incoming req: test.com/admin -> 127.0.0.1/goadmin (optional)
	Page    string   `json:"page"`    // page to serve instead of routing to targets - "<HTML>We are fixing it</HTML>" (optional)
}

type Server

type Server struct {
	// todo: change "Id" to "name" (for clarity)
	Id             string `json:"id,omitempty"`
	Host           string `json:"host"`
	Port           int    `json:"port"`
	Forwarder      string `json:"forwarder"`
	Weight         int    `json:"weight"`
	UpperThreshold int    `json:"upper_threshold"`
	LowerThreshold int    `json:"lower_threshold"`
}

func (*Server) GenHost

func (s *Server) GenHost(svcId string)

GenHost resets the server's Host it's service's Host if "127.0.0.1" was detected

func (*Server) GenId

func (s *Server) GenId()

type Service

type Service struct {
	Id          string   `json:"id,omitempty"`
	Host        string   `json:"host"`
	Interface   string   `json:"interface,omitempty"`
	Port        int      `json:"port"`
	Type        string   `json:"type"`
	Scheduler   string   `json:"scheduler"`
	Persistence int      `json:"persistence"`
	Netmask     string   `json:"netmask"`
	Servers     []Server `json:"servers,omitempty"`
}

func (*Service) GenHost

func (s *Service) GenHost() error

Because it is more common to use an address alias vs an actual virtual interface, we need to use ifconfig and pass in the "interface" (or alias) to get the address

func (*Service) GenId

func (s *Service) GenId()

type Vip

type Vip struct {
	Ip        string `json:"ip"`        // ip/cidr
	Interface string `json:"interface"` // interface to bind to
	Alias     string `json:"alias"`     // label for ip
}

type Vipable

type Vipable interface {
	// vips
	SetVip(vip Vip) error
	SetVips(vips []Vip) error
	DeleteVip(vip Vip) error
	GetVips() ([]Vip, error)
}

Directories

Path Synopsis
common contains all the logic to perform an action, as well as roll back other "systems" upon failure, effectively "undoing" the action.
common contains all the logic to perform an action, as well as roll back other "systems" upon failure, effectively "undoing" the action.

Jump to

Keyboard shortcuts

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