Registry router fixes (#1961)
* only cache routes if told to do so * Use roundrobin selector and retry in proxy * Update lookup to require service * Fix compile * Fix compile * Update * Update * rename query to lookup * Update router.go * Update
This commit is contained in:
parent
0c5eb5420c
commit
831dd19240
49
static.go
49
static.go
@ -10,12 +10,11 @@ func NewRouter(opts ...router.Option) router.Router {
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
return &static{options, new(table)}
|
||||
return &static{options}
|
||||
}
|
||||
|
||||
type static struct {
|
||||
options router.Options
|
||||
table router.Table
|
||||
}
|
||||
|
||||
func (s *static) Init(opts ...router.Option) error {
|
||||
@ -33,8 +32,18 @@ func (s *static) Table() router.Table {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *static) Lookup(opts ...router.QueryOption) ([]router.Route, error) {
|
||||
return s.table.Query(opts...)
|
||||
func (s *static) Lookup(service string, opts ...router.LookupOption) ([]router.Route, error) {
|
||||
options := router.NewLookup(opts...)
|
||||
|
||||
return []router.Route{
|
||||
router.Route{
|
||||
Address: service,
|
||||
Service: options.Address,
|
||||
Gateway: options.Gateway,
|
||||
Network: options.Network,
|
||||
Router: options.Router,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *static) Watch(opts ...router.WatchOption) (router.Watcher, error) {
|
||||
@ -48,35 +57,3 @@ func (s *static) Close() error {
|
||||
func (s *static) String() string {
|
||||
return "static"
|
||||
}
|
||||
|
||||
type table struct{}
|
||||
|
||||
func (t *table) Create(router.Route) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *table) Delete(router.Route) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *table) Update(router.Route) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *table) List() ([]router.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (t *table) Query(opts ...router.QueryOption) ([]router.Route, error) {
|
||||
options := router.NewQuery(opts...)
|
||||
|
||||
return []router.Route{
|
||||
router.Route{
|
||||
Address: options.Service,
|
||||
Service: options.Address,
|
||||
Gateway: options.Gateway,
|
||||
Network: options.Network,
|
||||
Router: options.Router,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user