Add proxy/router
This commit is contained in:
parent
fca89e06ef
commit
3e90d32f29
@ -2,6 +2,8 @@ package network
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/client"
|
||||
"github.com/micro/go-micro/network/proxy/mucp"
|
||||
"github.com/micro/go-micro/network/router"
|
||||
"github.com/micro/go-micro/server"
|
||||
)
|
||||
|
||||
@ -28,6 +30,8 @@ func NewNetwork(opts ...Option) Network {
|
||||
Name: DefaultName,
|
||||
Client: client.DefaultClient,
|
||||
Server: server.DefaultServer,
|
||||
Proxy: mucp.NewProxy(),
|
||||
Router: router.DefaultRouter,
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
@ -37,6 +41,7 @@ func NewNetwork(opts ...Option) Network {
|
||||
// set the server name
|
||||
options.Server.Init(
|
||||
server.Name(options.Name),
|
||||
server.WithRouter(options.Proxy),
|
||||
)
|
||||
|
||||
return &network{
|
||||
|
@ -2,6 +2,8 @@ package network
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/client"
|
||||
"github.com/micro/go-micro/network/proxy"
|
||||
"github.com/micro/go-micro/network/router"
|
||||
"github.com/micro/go-micro/server"
|
||||
)
|
||||
|
||||
@ -11,6 +13,8 @@ type Options struct {
|
||||
Name string
|
||||
Client client.Client
|
||||
Server server.Server
|
||||
Proxy proxy.Proxy
|
||||
Router router.Router
|
||||
}
|
||||
|
||||
// The network name
|
||||
@ -33,3 +37,19 @@ func Server(s server.Server) Option {
|
||||
o.Server = s
|
||||
}
|
||||
}
|
||||
|
||||
// The proxy to use
|
||||
func Proxy(p proxy.Proxy) Option {
|
||||
return func(o *Options) {
|
||||
o.Proxy = p
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// The router to use
|
||||
func Router(r router.Router) Option {
|
||||
return func(o *Options) {
|
||||
o.Router = r
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user