github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/docs/v2/design/framework/router.md (about) 1 # Router 2 3 The router is the micro routing control plane. It manages intelligent routing on top of the registry. 4 5 ## Overview 6 7 The router is a layer on top of the micro registry which provides intelligent routing based on metrics, feedback 8 and other router information. The registry is a dumb database of sorts. The router enables us to build 9 a network topology that morphs and flows based on changing traffic patterns. 10 11 ## Usage 12 13 The router is primarily a package in go-micro that is leveraged by the client/selector and proxy. 14 The selector does a route Lookup for a service and gets back optimal routes in an ordered list. 15 It can provide feedback to the router about how that route performed which can then be used to 16 change the metrics associated with this route. In the event the router receives the same routes 17 from other routers with different metrics it can take this into consideration. 18 19 The router additionally stores the metadata associated with each service and its nodes and can 20 use these for dynamic label based routing. Where the path the request take is based on the label 21 associated with the service rather than the address. 22 23 ## Interface 24 25 Rough interface reference 26 27 ```go 28 type Router interface { 29 // lookup a service, additionally provide label filters 30 Lookup(service, ...opts) ([]Route, error) 31 // Update the metrics for a route 32 Update(Route, Metric) error 33 // Advertise routes 34 Advertise() (<-chan Route, error) 35 // Process adverts 36 Process(Route) error 37 // Get router status 38 Status() (Info, error) 39 } 40 41 type Route struct { 42 Service string 43 Address string 44 Metadata map[string]string 45 Metric float64 46 } 47 ``` 48