Renaming rampage
Addressing the comments in #591, router.String() now returns "default" Furthermore, a tonne of other renaming has been included in this commit as a result of running go vet ./... inside the router package.
This commit is contained in:
parent
92495d22db
commit
2803146673
@ -160,7 +160,7 @@ func (r *router) manageRegistryRoutes(reg registry.Registry, action string) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
// watchRegistry watches sregistry and updates the routing table.
|
||||
// watchRegistry watches registry and updates routing table based on the received events.
|
||||
// It returns error if either the registry watcher fails with error or if the routing table update fails.
|
||||
func (r *router) watchRegistry(w registry.Watcher) error {
|
||||
// wait in the background for the router to stop
|
||||
@ -282,8 +282,6 @@ func (r *router) advertiseTable() error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// routeAdvert contains a list of route events to be advertised
|
||||
@ -400,10 +398,6 @@ func (r *router) processEvents() error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// we probably never reach this code path
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// watchErrors watches router errors and takes appropriate actions
|
||||
@ -609,5 +603,5 @@ func (r *router) Stop() error {
|
||||
|
||||
// String prints debugging information about router
|
||||
func (r *router) String() string {
|
||||
return "default router"
|
||||
return "default"
|
||||
}
|
||||
|
@ -7,14 +7,14 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// TableOptions specify routing table options
|
||||
// Options specify routing table options
|
||||
// TODO: table options TBD in the future
|
||||
type TableOptions struct{}
|
||||
type Options struct{}
|
||||
|
||||
// table is an in memory routing table
|
||||
type table struct {
|
||||
// opts are table options
|
||||
opts TableOptions
|
||||
opts Options
|
||||
// m stores routing table map
|
||||
m map[string]map[uint64]Route
|
||||
// w is a list of table watchers
|
||||
@ -23,9 +23,9 @@ type table struct {
|
||||
}
|
||||
|
||||
// newTable creates a new routing table and returns it
|
||||
func newTable(opts ...TableOption) Table {
|
||||
func newTable(opts ...Option) Table {
|
||||
// default options
|
||||
var options TableOptions
|
||||
var options Options
|
||||
|
||||
// apply requested options
|
||||
for _, o := range opts {
|
||||
@ -40,7 +40,7 @@ func newTable(opts ...TableOption) Table {
|
||||
}
|
||||
|
||||
// Init initializes routing table with options
|
||||
func (t *table) Init(opts ...TableOption) error {
|
||||
func (t *table) Init(opts ...Option) error {
|
||||
for _, o := range opts {
|
||||
o(&t.opts)
|
||||
}
|
||||
@ -48,7 +48,7 @@ func (t *table) Init(opts ...TableOption) error {
|
||||
}
|
||||
|
||||
// Options returns routing table options
|
||||
func (t *table) Options() TableOptions {
|
||||
func (t *table) Options() Options {
|
||||
return t.opts
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ func (t *table) Size() int {
|
||||
defer t.RUnlock()
|
||||
|
||||
size := 0
|
||||
for dest, _ := range t.m {
|
||||
for dest := range t.m {
|
||||
size += len(t.m[dest])
|
||||
}
|
||||
|
||||
@ -227,6 +227,6 @@ func (t *table) Size() int {
|
||||
}
|
||||
|
||||
// String returns debug information
|
||||
func (t table) String() string {
|
||||
return "table"
|
||||
func (t *table) String() string {
|
||||
return "default"
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestCreate(t *testing.T) {
|
||||
if err := table.Create(route); err != nil {
|
||||
t.Errorf("error adding route: %s", err)
|
||||
}
|
||||
testTableSize += 1
|
||||
testTableSize++
|
||||
|
||||
// adds new route for the original destination
|
||||
route.Gateway = "dest.gw2"
|
||||
@ -31,7 +31,7 @@ func TestCreate(t *testing.T) {
|
||||
if err := table.Create(route); err != nil {
|
||||
t.Errorf("error adding route: %s", err)
|
||||
}
|
||||
testTableSize += 1
|
||||
testTableSize++
|
||||
|
||||
if table.Size() != testTableSize {
|
||||
t.Errorf("invalid number of routes. Expected: %d, found: %d", testTableSize, table.Size())
|
||||
@ -50,7 +50,7 @@ func TestDelete(t *testing.T) {
|
||||
if err := table.Create(route); err != nil {
|
||||
t.Errorf("error adding route: %s", err)
|
||||
}
|
||||
testTableSize += 1
|
||||
testTableSize++
|
||||
|
||||
// should fail to delete non-existant route
|
||||
prevSvc := route.Service
|
||||
@ -66,7 +66,7 @@ func TestDelete(t *testing.T) {
|
||||
if err := table.Delete(route); err != nil {
|
||||
t.Errorf("error deleting route: %s", err)
|
||||
}
|
||||
testTableSize -= 1
|
||||
testTableSize--
|
||||
|
||||
if table.Size() != testTableSize {
|
||||
t.Errorf("invalid number of routes. Expected: %d, found: %d", testTableSize, table.Size())
|
||||
@ -80,7 +80,7 @@ func TestUpdate(t *testing.T) {
|
||||
if err := table.Create(route); err != nil {
|
||||
t.Errorf("error adding route: %s", err)
|
||||
}
|
||||
testTableSize += 1
|
||||
testTableSize++
|
||||
|
||||
// change the metric of the original route
|
||||
route.Metric = 200
|
||||
@ -100,7 +100,7 @@ func TestUpdate(t *testing.T) {
|
||||
if err := table.Update(route); err != nil {
|
||||
t.Errorf("error updating route: %s", err)
|
||||
}
|
||||
testTableSize += 1
|
||||
testTableSize++
|
||||
|
||||
if table.Size() != testTableSize {
|
||||
t.Errorf("invalid number of routes. Expected: %d, found: %d", testTableSize, table.Size())
|
||||
|
@ -29,10 +29,10 @@ type Table interface {
|
||||
Size() int
|
||||
}
|
||||
|
||||
// TableOption used by the routing table
|
||||
type TableOption func(*TableOptions)
|
||||
// Option used by the routing table
|
||||
type Option func(*Options)
|
||||
|
||||
// NewTable creates new routing table and returns it
|
||||
func NewTable(opts ...TableOption) Table {
|
||||
func NewTable(opts ...Option) Table {
|
||||
return newTable(opts...)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user