This commit adds the following changes to router package:
* it refactors Advertise() function which now does only what
it claims to do: advertising
* various router packages functions/methods have been renamed to make
their functionality more obvious and more in line with what they actually do
* function documentation changes related to the above bullet points
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 adds the following changes:
* advert now stores a list of route events as opposed to just last one
* attempt to dedup route events before appending them to advert
* have max suppress threshold for long time suppressed adverts
* decaying events on every advert tick
Originally we werent decaying penalties on every advert tick.
That was incorrect behaviour. Furthermore some events would end up being
accumulated potentially causing memory leaks.
We were also overriding the last received router event which was causing
incorrect sequence of events to be applied when received by a receiver:
Create, Delete would be "squashed" into Delete only which would be
nonsensical since the Create event would never be delivered hence we
would be deleting nonexistent routes.
Not Decaying the events on every tick or not having the max suppression
threshold could lead to DoS by growing the router memory infinitely.
We now manage routing table actions using dedicated functions run on
either registry or services in the registry.
Routing table now uses Route.Hash() instead of maintaining its own hash
struct filed which previously performed these operations.
Various names of variables have been changed to make them more concise.
In order to differentiate between intialized and other states we
introduced a new state: Init. The router is in this state only when it's
created.
We have cleaned up router status management which is now handled by
manageStatus function only.
* Changed router interface to return Advertisement channel
* Added default gateway route to the routing table if supplied
* Watch table for updates and advertise to the network
* We hash the routes on 3-tuple (Destination, Gateway, Network)
gw has not been initialized; it was basically an empty string and only
got populated by Sprintf-ing the addr:port IF the port has been set.
This commit sets the gw to node.Address to it's never an empty string.