cleanup client/selector/lookup (#1937)

* cleanup client/selector/lookup

* add mdns router, remove registry from client

* fix roundtripper

* remove comment

* fix compile issue

* fix mucp test

* fix api router
This commit is contained in:
Asim Aslam
2020-08-17 22:44:45 +01:00
committed by GitHub
parent 7135787b78
commit 50ec6c748f
17 changed files with 398 additions and 418 deletions

View File

@@ -7,10 +7,10 @@ import (
"github.com/micro/go-micro/v3/broker"
"github.com/micro/go-micro/v3/broker/http"
"github.com/micro/go-micro/v3/codec"
"github.com/micro/go-micro/v3/registry"
"github.com/micro/go-micro/v3/router"
regRouter "github.com/micro/go-micro/v3/router/registry"
"github.com/micro/go-micro/v3/selector"
"github.com/micro/go-micro/v3/selector/random"
"github.com/micro/go-micro/v3/transport"
thttp "github.com/micro/go-micro/v3/transport/http"
)
@@ -28,6 +28,9 @@ type Options struct {
Selector selector.Selector
Transport transport.Transport
// Lookup used for looking up routes
Lookup LookupFunc
// Connection Pool
PoolSize int
PoolTTL time.Duration
@@ -116,11 +119,12 @@ func NewOptions(options ...Option) Options {
RequestTimeout: DefaultRequestTimeout,
DialTimeout: transport.DefaultDialTimeout,
},
Lookup: LookupRoute,
PoolSize: DefaultPoolSize,
PoolTTL: DefaultPoolTTL,
Broker: http.NewBroker(),
Router: regRouter.NewRouter(),
Selector: selector.DefaultSelector,
Selector: random.NewSelector(),
Transport: thttp.NewTransport(),
}
@@ -216,6 +220,13 @@ func Backoff(fn BackoffFunc) Option {
}
}
// Lookup sets the lookup function to use for resolving service names
func Lookup(l LookupFunc) Option {
return func(o *Options) {
o.Lookup = l
}
}
// Number of retries when making the request.
// Should this be a Call Option?
func Retries(i int) Option {
@@ -231,13 +242,6 @@ func Retry(fn RetryFunc) Option {
}
}
// Registry sets the routers registry
func Registry(r registry.Registry) Option {
return func(o *Options) {
o.Router.Init(router.Registry(r))
}
}
// The request timeout.
// Should this be a Call Option?
func RequestTimeout(d time.Duration) Option {