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
|
||||
}
|
||||
|
||||
// add all local service routes into the routing table
|
||||
if err := r.manageRegistryRoutes(r.options.Registry, "create"); err != nil {
|
||||
return fmt.Errorf("failed adding registry routes: %s", err)
|
||||
if r.options.Prewarm {
|
||||
// add all local service routes into the routing table
|
||||
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
|
||||
|
@ -23,6 +23,8 @@ type Options struct {
|
||||
Advertise Strategy
|
||||
// Context for additional options
|
||||
Context context.Context
|
||||
// Prewarm the route table on router startup
|
||||
Prewarm bool
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return func(o *Options) {
|
||||
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
|
||||
func DefaultOptions() Options {
|
||||
return Options{
|
||||
|
Loading…
Reference in New Issue
Block a user