router: add to service options; add dns and static implementations (#1733)
* config/cmd: add router to service options * router/service: use micro client
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/micro/go-micro/v2/debug/profile"
|
||||
"github.com/micro/go-micro/v2/debug/trace"
|
||||
"github.com/micro/go-micro/v2/registry"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v2/runtime"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
"github.com/micro/go-micro/v2/store"
|
||||
@@ -31,6 +32,7 @@ type Options struct {
|
||||
Config *config.Config
|
||||
Client *client.Client
|
||||
Server *server.Server
|
||||
Router *router.Router
|
||||
Runtime *runtime.Runtime
|
||||
Store *store.Store
|
||||
Tracer *trace.Tracer
|
||||
@@ -44,6 +46,7 @@ type Options struct {
|
||||
Selectors map[string]func(...selector.Option) selector.Selector
|
||||
Servers map[string]func(...server.Option) server.Server
|
||||
Transports map[string]func(...transport.Option) transport.Transport
|
||||
Routers map[string]func(...router.Option) router.Router
|
||||
Runtimes map[string]func(...runtime.Option) runtime.Runtime
|
||||
Stores map[string]func(...store.Option) store.Store
|
||||
Tracers map[string]func(...trace.Option) trace.Tracer
|
||||
@@ -100,6 +103,12 @@ func Registry(r *registry.Registry) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func Router(r *router.Router) Option {
|
||||
return func(o *Options) {
|
||||
o.Router = r
|
||||
}
|
||||
}
|
||||
|
||||
func Runtime(r *runtime.Runtime) Option {
|
||||
return func(o *Options) {
|
||||
o.Runtime = r
|
||||
@@ -190,6 +199,13 @@ func NewTransport(name string, t func(...transport.Option) transport.Transport)
|
||||
}
|
||||
}
|
||||
|
||||
// New router func
|
||||
func NewRouter(name string, r func(...router.Option) router.Router) Option {
|
||||
return func(o *Options) {
|
||||
o.Routers[name] = r
|
||||
}
|
||||
}
|
||||
|
||||
// New runtime func
|
||||
func NewRuntime(name string, r func(...runtime.Option) runtime.Runtime) Option {
|
||||
return func(o *Options) {
|
||||
|
||||
Reference in New Issue
Block a user