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:
ben-toogood
2020-06-24 11:46:51 +01:00
committed by GitHub
parent c940961574
commit a2550820d3
8 changed files with 319 additions and 15 deletions

View File

@@ -1,8 +1,9 @@
package router
import (
"context"
"github.com/google/uuid"
"github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/registry"
)
@@ -20,8 +21,8 @@ type Options struct {
Registry registry.Registry
// Advertise is the advertising strategy
Advertise Strategy
// Client for calling router
Client client.Client
// Context for additional options
Context context.Context
}
// Id sets Router Id
@@ -38,13 +39,6 @@ func Address(a string) Option {
}
}
// Client to call router service
func Client(c client.Client) Option {
return func(o *Options) {
o.Client = c
}
}
// Gateway sets network gateway
func Gateway(g string) Option {
return func(o *Options) {
@@ -81,5 +75,6 @@ func DefaultOptions() Options {
Network: DefaultNetwork,
Registry: registry.DefaultRegistry,
Advertise: AdvertiseLocal,
Context: context.Background(),
}
}