From 3e90d32f29b20ec5609e2716575505eda3a8218a Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 31 Jul 2019 15:30:51 +0100 Subject: [PATCH] Add proxy/router --- network/default.go | 5 +++++ network/options.go | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/network/default.go b/network/default.go index d384a5f4..13876e57 100644 --- a/network/default.go +++ b/network/default.go @@ -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{ diff --git a/network/options.go b/network/options.go index 9dcbb1ed..2a211ea5 100644 --- a/network/options.go +++ b/network/options.go @@ -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 + } + +}