66 lines
1.1 KiB
Go
66 lines
1.1 KiB
Go
package router
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// Options allows to set Router options
|
|
type Options struct {
|
|
// ID is router ID
|
|
ID string
|
|
// Address is router address
|
|
Address string
|
|
// GossipAddr is router gossip address
|
|
GossipAddr string
|
|
// NetworkAddr defines micro network address
|
|
NetworkAddr string
|
|
// RIB is Routing Information Base
|
|
RIB RIB
|
|
// Table is routing table
|
|
Table Table
|
|
// Context stores arbitrary options
|
|
Context context.Context
|
|
}
|
|
|
|
// ID sets Router ID
|
|
func ID(id string) Option {
|
|
return func(o *Options) {
|
|
o.ID = id
|
|
}
|
|
}
|
|
|
|
// Address sets router address
|
|
func Address(a string) Option {
|
|
return func(o *Options) {
|
|
o.Address = a
|
|
}
|
|
}
|
|
|
|
// GossipAddr sets router gossip address
|
|
func GossipAddr(a string) Option {
|
|
return func(o *Options) {
|
|
o.GossipAddr = a
|
|
}
|
|
}
|
|
|
|
// NetworkAddr sets router network address
|
|
func NetworkAddr(n string) Option {
|
|
return func(o *Options) {
|
|
o.NetworkAddr = n
|
|
}
|
|
}
|
|
|
|
// RIBase allows to configure RIB
|
|
func RIBase(r RIB) Option {
|
|
return func(o *Options) {
|
|
o.RIB = r
|
|
}
|
|
}
|
|
|
|
// RoutingTable allows to specify custom routing table
|
|
func RoutingTable(t Table) Option {
|
|
return func(o *Options) {
|
|
o.Table = t
|
|
}
|
|
}
|