router

package
v0.0.0-...-47649f3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: BSD-3-Clause Imports: 13 Imported by: 14

Documentation

Overview

Package router provides interfaces that need to be satisfied in order to implement a new router on tsuru.

Index

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 Default

func Default(ctx context.Context) (string, error)

Default returns the default router

func DynamicRouterService

func DynamicRouterService() (routerTypes.DynamicRouterService, error)

func InstrumentRequest

func InstrumentRequest(routerName string) func(error)

func List

func List(ctx context.Context) ([]router.PlanRouter, error)

func ListWithInfo

func ListWithInfo(ctx context.Context) ([]router.PlanRouter, error)

func Register

func Register(name string, r routerFactory)

Register registers a new router.

func Unregister

func Unregister(name string)

func ValidCName

func ValidCName(cname, domain string) bool

validCName returns true if the cname is not a subdomain of the router current domain, false otherwise.

Types

type App

type App interface {
	GetName() string
	GetPool() string
	GetTeamOwner() string
	GetTeamsName() []string
}

App is the interface implemented by routable applications.

type BackendPrefix

type BackendPrefix struct {
	Prefix string            `json:"prefix"`
	Target map[string]string `json:"target"` // in kubernetes cluster be like {serviceName: "", namespace: ""}
}

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"`
	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 App, o EnsureBackendOpts) error
	RemoveBackend(ctx context.Context, app App) error

	Addresses(ctx context.Context, app App) ([]string, error)

	GetInfo(ctx context.Context) (map[string]string, error)
	GetBackendStatus(ctx context.Context, app 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 Get

func Get(ctx context.Context, name string) (Router, error)

Get gets the named router from the registry.

func GetWithPlanRouter

func GetWithPlanRouter(ctx context.Context, name string) (Router, router.PlanRouter, error)

type RouterBackendStatus

type RouterBackendStatus struct {
	Status BackendStatus `json:"status"`
	Detail string        `json:"detail"`
}

type RouterError

type RouterError struct {
	Op  string
	Err error
}

func (*RouterError) Error

func (e *RouterError) Error() string

type TLSRouter

type TLSRouter interface {
	AddCertificate(ctx context.Context, app App, cname, certificate, key string) error
	RemoveCertificate(ctx context.Context, app App, cname string) error
	GetCertificate(ctx context.Context, app App, cname string) (string, error)
}

TLSRouter is a router that supports adding and removing certificates for a given cname

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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