Documentation ¶
Overview ¶
Package router provides interfaces that need to be satisfied in order to implement a new router on tsuru.
Index ¶
- Constants
- Variables
- func Default(ctx context.Context) (string, error)
- func DynamicRouterService() (routerTypes.DynamicRouterService, error)
- func InstrumentRequest(routerName string) func(error)
- func List(ctx context.Context) ([]router.PlanRouter, error)
- func ListWithInfo(ctx context.Context) ([]router.PlanRouter, error)
- func Register(name string, r routerFactory)
- func Unregister(name string)
- func ValidCName(cname, domain string) bool
- type BackendPrefix
- type BackendStatus
- type ConfigGetter
- type EnsureBackendOpts
- type ErrRouterNotFound
- type Router
- type RouterBackendStatus
- type RouterError
- type TLSRouter
Constants ¶
View Source
const HttpScheme = "http"
Variables ¶
View Source
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") ErrSwapAmongDifferentClusters = errors.New("Could not swap apps among different clusters") )
View Source
var ( BackendStatusReady = BackendStatus("ready") BackendStatusNotReady = BackendStatus("not ready") )
View Source
var ConfigGetterFromData = configGetterFromData
Functions ¶
func DynamicRouterService ¶
func DynamicRouterService() (routerTypes.DynamicRouterService, error)
func InstrumentRequest ¶
func ListWithInfo ¶
func ListWithInfo(ctx context.Context) ([]router.PlanRouter, error)
func Unregister ¶
func Unregister(name string)
func ValidCName ¶
validCName returns true if the cname is not a subdomain of the router current domain, false otherwise.
Types ¶
type BackendPrefix ¶
type BackendStatus ¶
type BackendStatus string
type ConfigGetter ¶
type ConfigGetter interface { GetString(string) (string, error) GetList(string) ([]string, error) GetInt(string) (int, error) GetFloat(string) (float64, error) GetBool(string) (bool, error) Get(string) (interface{}, error) Hash() (string, error) }
func ConfigGetterFromPrefix ¶
func ConfigGetterFromPrefix(prefix string) ConfigGetter
type EnsureBackendOpts ¶
type EnsureBackendOpts struct { Opts map[string]interface{} `json:"opts"` CNames []string `json:"cnames"` Team string `json:"team,omitempty"` Tags []string `json:"tags,omitempty"` CertIssuers map[string]string `json:"certIssuers,omitempty"` Prefixes []BackendPrefix `json:"prefixes"` Healthcheck router.HealthcheckData `json:"healthcheck"` }
type ErrRouterNotFound ¶
type ErrRouterNotFound struct {
Name string
}
func (*ErrRouterNotFound) Error ¶
func (e *ErrRouterNotFound) Error() string
type Router ¶
type Router interface { GetName() string GetType() string EnsureBackend(ctx context.Context, app *appTypes.App, o EnsureBackendOpts) error RemoveBackend(ctx context.Context, app *appTypes.App) error Addresses(ctx context.Context, app *appTypes.App) ([]string, error) GetInfo(ctx context.Context) (map[string]string, error) GetBackendStatus(ctx context.Context, app *appTypes.App) (status RouterBackendStatus, err error) }
Router is the basic interface of this package. It provides methods for managing backends and routes. Each backend can have multiple routes.
func GetWithPlanRouter ¶
type RouterBackendStatus ¶
type RouterBackendStatus struct { Status BackendStatus `json:"status"` Detail string `json:"detail"` }
type RouterError ¶
func (*RouterError) Error ¶
func (e *RouterError) Error() string
type TLSRouter ¶
type TLSRouter interface { AddCertificate(ctx context.Context, app *appTypes.App, cname, certificate, key string) error RemoveCertificate(ctx context.Context, app *appTypes.App, cname string) error GetCertificate(ctx context.Context, app *appTypes.App, cname string) (string, error) }
TLSRouter is a router that supports adding and removing certificates for a given cname
Click to show internal directories.
Click to hide internal directories.