Remove quic transport, move route into router
This commit is contained in:
@@ -136,7 +136,7 @@ func (r *rtr) createRoutes(service *registry.Service, network string) []router.R
|
||||
Network: network,
|
||||
Router: r.options.Id,
|
||||
Link: router.DefaultLink,
|
||||
Metric: router.DefaultLocalMetric,
|
||||
Metric: router.DefaultMetric,
|
||||
Metadata: node.Metadata,
|
||||
})
|
||||
}
|
||||
@@ -376,7 +376,7 @@ func (r *rtr) start() error {
|
||||
Network: "*",
|
||||
Router: r.options.Id,
|
||||
Link: router.DefaultLink,
|
||||
Metric: router.DefaultLocalMetric,
|
||||
Metric: router.DefaultMetric,
|
||||
}
|
||||
if err := r.table.Create(route); err != nil {
|
||||
return fmt.Errorf("failed adding default gateway route: %s", err)
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"hash/fnv"
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultLink is default network link
|
||||
DefaultLink = "local"
|
||||
// DefaultLocalMetric is default route cost for a local route
|
||||
DefaultLocalMetric int64 = 1
|
||||
)
|
||||
|
||||
// Route is network route
|
||||
type Route struct {
|
||||
// Service is destination service name
|
||||
Service string
|
||||
// Address is service node address
|
||||
Address string
|
||||
// Gateway is route gateway
|
||||
Gateway string
|
||||
// Network is network address
|
||||
Network string
|
||||
// Router is router id
|
||||
Router string
|
||||
// Link is network link
|
||||
Link string
|
||||
// Metric is the route cost metric
|
||||
Metric int64
|
||||
// Metadata for the route
|
||||
Metadata map[string]string
|
||||
}
|
||||
|
||||
// Hash returns route hash sum.
|
||||
func (r *Route) Hash() uint64 {
|
||||
h := fnv.New64()
|
||||
h.Reset()
|
||||
h.Write([]byte(r.Service + r.Address + r.Gateway + r.Network + r.Router + r.Link))
|
||||
return h.Sum64()
|
||||
}
|
||||
@@ -3,9 +3,14 @@ package router
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hash/fnv"
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultLink is default network link
|
||||
DefaultLink = "local"
|
||||
// DefaultLocalMetric is default route cost for a local route
|
||||
DefaultMetric int64 = 1
|
||||
// DefaultNetwork is default micro network
|
||||
DefaultNetwork = "micro"
|
||||
// ErrRouteNotFound is returned when no route was found in the routing table
|
||||
@@ -60,3 +65,31 @@ const (
|
||||
// Error means the router has encountered error
|
||||
Error
|
||||
)
|
||||
|
||||
// Route is a network route
|
||||
type Route struct {
|
||||
// Service is destination service name
|
||||
Service string
|
||||
// Address is service node address
|
||||
Address string
|
||||
// Gateway is route gateway
|
||||
Gateway string
|
||||
// Network is network address
|
||||
Network string
|
||||
// Router is router id
|
||||
Router string
|
||||
// Link is network link
|
||||
Link string
|
||||
// Metric is the route cost metric
|
||||
Metric int64
|
||||
// Metadata for the route
|
||||
Metadata map[string]string
|
||||
}
|
||||
|
||||
// Hash returns route hash sum.
|
||||
func (r *Route) Hash() uint64 {
|
||||
h := fnv.New64()
|
||||
h.Reset()
|
||||
h.Write([]byte(r.Service + r.Address + r.Gateway + r.Network + r.Router + r.Link))
|
||||
return h.Sum64()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user