Documentation ¶
Index ¶
Constants ¶
const ( RouteTypePrefix = "prefix" RouteTypeExact = "exact" )
const ( SegmentsModePreserve = "preserve" SegmentsModeIgnore = "ignore" )
Variables ¶
var EnableDebugOutput bool
Functions ¶
func RegisterMetrics ¶
func RegisterMetrics(r prometheus.Registerer)
RegisterMetrics registers Prometheus metrics from the router module and the modules that it directly depends on. To use the default (global) registry, pass prometheus.DefaultRegisterer.
func VersionInfo ¶
func VersionInfo() (v string)
VersionInfo returns human-readable version information in a format suitable for concatenation with other messages.
Types ¶
type Backend ¶
type MongoReplicaSet ¶
type MongoReplicaSet struct {
Members []MongoReplicaSetMember `bson:"members"`
}
type MongoReplicaSetMember ¶
type MongoReplicaSetMember struct { Name string `bson:"name"` Optime bson.MongoTimestamp `bson:"optime"` Current bool `bson:"self"` }
type Route ¶
type Route struct { IncomingPath string `bson:"incoming_path"` RouteType string `bson:"route_type"` Handler string `bson:"handler"` BackendID string `bson:"backend_id"` RedirectTo string `bson:"redirect_to"` RedirectType string `bson:"redirect_type"` SegmentsMode string `bson:"segments_mode"` Disabled bool `bson:"disabled"` }
type Router ¶
type Router struct { ReloadChan chan bool // contains filtered or unexported fields }
Router is a wrapper around an HTTP multiplexer (trie.Mux) which retrieves its routes from a passed mongo database.
TODO: decouple Router from its database backend. Router should not know anything about the database backend. Its representation of the route table should be independent of the underlying DBMS. Route should define an abstract interface for some other module to be able to bulk-load and incrementally update routes. Since Router should not care where its routes come from, Route and Backend should not contain bson fields. MongoReplicaSet, MongoReplicaSetMember etc. should move out of this module.
func NewRouter ¶
NewRouter returns a new empty router instance. You will need to call SelfUpdateRoutes() to initialise the self-update process for routes.
func (*Router) SelfUpdateRoutes ¶
func (rt *Router) SelfUpdateRoutes()