only prewarm the route table if requested (#1765)
This commit is contained in:
parent
dcf01ebbf0
commit
58845d7012
@ -467,9 +467,11 @@ func (r *router) start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all local service routes into the routing table
|
if r.options.Prewarm {
|
||||||
if err := r.manageRegistryRoutes(r.options.Registry, "create"); err != nil {
|
// add all local service routes into the routing table
|
||||||
return fmt.Errorf("failed adding registry routes: %s", err)
|
if err := r.manageRegistryRoutes(r.options.Registry, "create"); err != nil {
|
||||||
|
return fmt.Errorf("failed adding registry routes: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add default gateway into routing table
|
// add default gateway into routing table
|
||||||
|
@ -23,6 +23,8 @@ type Options struct {
|
|||||||
Advertise Strategy
|
Advertise Strategy
|
||||||
// Context for additional options
|
// Context for additional options
|
||||||
Context context.Context
|
Context context.Context
|
||||||
|
// Prewarm the route table on router startup
|
||||||
|
Prewarm bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Id sets Router Id
|
// Id sets Router Id
|
||||||
@ -60,13 +62,20 @@ func Registry(r registry.Registry) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strategy sets route advertising strategy
|
// Advertise sets route advertising strategy
|
||||||
func Advertise(a Strategy) Option {
|
func Advertise(a Strategy) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Advertise = a
|
o.Advertise = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prewarm sets whether to prewarm the route table
|
||||||
|
func Prewarm(b bool) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Prewarm = b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DefaultOptions returns router default options
|
// DefaultOptions returns router default options
|
||||||
func DefaultOptions() Options {
|
func DefaultOptions() Options {
|
||||||
return Options{
|
return Options{
|
||||||
|
Loading…
Reference in New Issue
Block a user