Documentation ¶
Overview ¶
Package router provides interfaces that need to be satisfied in order to implement a new router on tsuru.
Index ¶
- Constants
- Variables
- func BuildHealthCheck(routerName string) func() error
- func Default() (string, error)
- func Initialize() error
- func InstrumentRequest(routerName string) func(error)
- func IsSwapped(name string) (bool, string, error)
- func MigrateUniqueCollection() error
- func Register(name string, r routerFactory)
- func Remove(appName string) error
- func Retrieve(appName string) (string, error)
- func Store(appName, routerName, kind string) error
- func Swap(r Router, backend1, backend2 string, cnameOnly bool) error
- func Type(name string) (string, string, error)
- func ValidCName(cname, domain string) bool
- type CNameRouter
- type CustomHealthcheckRouter
- type ErrRouterNotFound
- type HealthChecker
- type HealthcheckData
- type MessageRouter
- type OptsRouter
- type PlanRouter
- type Router
- type RouterError
- type TLSRouter
Constants ¶
const HttpScheme = "http"
Variables ¶
var ( ErrBackendExists = errors.New("Backend already exists") ErrBackendNotFound = errors.New("Backend not found") ErrBackendSwapped = errors.New("Backend is swapped cannot remove") ErrRouteNotFound = errors.New("Route not found") ErrCNameExists = errors.New("CName already exists") ErrCNameNotFound = errors.New("CName not found") ErrCNameNotAllowed = errors.New("CName as router subdomain not allowed") ErrCertificateNotFound = errors.New("Certificate not found") ErrDefaultRouterNotFound = errors.New("No default router found") )
Functions ¶
func BuildHealthCheck ¶
BuildHealthCheck creates a healthcheck function for the given routerName.
It will call the HealthCheck() method in the router (only if it's also a HealthChecker), for each instance of it (including the "main" instance and all custom routers).
func Initialize ¶
func Initialize() error
func InstrumentRequest ¶
func MigrateUniqueCollection ¶
func MigrateUniqueCollection() error
MigrateUniqueCollection only exists because old versions of tsuru (<1.2.0) allowed the insertion of incorrect duplicated entries in the db.routers collection. This migration tries its best to fix the inconsistencies in this collection and fails if that's not possible.
func ValidCName ¶
validCName returns true if the cname is not a subdomain of the router current domain, false otherwise.
Types ¶
type CNameRouter ¶
type CustomHealthcheckRouter ¶
type CustomHealthcheckRouter interface {
SetHealthcheck(name string, data HealthcheckData) error
}
type ErrRouterNotFound ¶
type ErrRouterNotFound struct {
Name string
}
func (*ErrRouterNotFound) Error ¶
func (e *ErrRouterNotFound) Error() string
type HealthChecker ¶
type HealthChecker interface {
HealthCheck() error
}
type HealthcheckData ¶
type MessageRouter ¶
type OptsRouter ¶
type PlanRouter ¶
type PlanRouter struct { Name string `json:"name"` Type string `json:"type"` Default bool `json:"default"` }
func List ¶
func List() ([]PlanRouter, error)
type Router ¶
type Router interface { GetName() string AddBackend(name string) error RemoveBackend(name string) error AddRoutes(name string, address []*url.URL) error RemoveRoutes(name string, addresses []*url.URL) error Addr(name string) (string, error) // Swap change the router between two backends. Swap(backend1, backend2 string, cnameOnly bool) error // Routes returns a list of routes of a backend. Routes(name string) ([]*url.URL, error) }
Router is the basic interface of this package. It provides methods for managing backends and routes. Each backend can have multiple routes.
type RouterError ¶
func (*RouterError) Error ¶
func (e *RouterError) Error() string
Directories ¶
Path | Synopsis |
---|---|
Package hipache provides a router implementation that store routes in Redis, as specified by Hipache (https://github.com/dotcloud/hipache).
|
Package hipache provides a router implementation that store routes in Redis, as specified by Hipache (https://github.com/dotcloud/hipache). |