v3 refactor (#1868)
* Move to v3 Co-authored-by: Ben Toogood <bentoogood@gmail.com>
This commit is contained in:
@@ -6,11 +6,11 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/client/grpc"
|
||||
"github.com/micro/go-micro/v2/codec"
|
||||
"github.com/micro/go-micro/v2/proxy"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
"github.com/micro/go-micro/v3/client"
|
||||
"github.com/micro/go-micro/v3/client/grpc"
|
||||
"github.com/micro/go-micro/v3/codec"
|
||||
"github.com/micro/go-micro/v3/proxy"
|
||||
"github.com/micro/go-micro/v3/server"
|
||||
)
|
||||
|
||||
// Proxy will transparently proxy requests to the backend.
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"github.com/micro/go-micro/v2/errors"
|
||||
"github.com/micro/go-micro/v2/proxy"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
"github.com/micro/go-micro/v3/errors"
|
||||
"github.com/micro/go-micro/v3/proxy"
|
||||
"github.com/micro/go-micro/v3/server"
|
||||
)
|
||||
|
||||
// Proxy will proxy rpc requests as http POST requests. It is a server.Proxy
|
||||
|
||||
@@ -8,10 +8,11 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/micro/go-micro/v2"
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/registry/memory"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
"github.com/micro/go-micro/v3/client"
|
||||
"github.com/micro/go-micro/v3/registry/memory"
|
||||
"github.com/micro/go-micro/v3/server"
|
||||
"github.com/micro/go-micro/v3/service"
|
||||
"github.com/micro/go-micro/v3/service/mucp"
|
||||
)
|
||||
|
||||
type testHandler struct{}
|
||||
@@ -56,11 +57,11 @@ func TestHTTPProxy(t *testing.T) {
|
||||
wg.Add(1)
|
||||
|
||||
// new micro service
|
||||
service := micro.NewService(
|
||||
micro.Context(ctx),
|
||||
micro.Name("foobar"),
|
||||
micro.Registry(memory.NewRegistry()),
|
||||
micro.AfterStart(func() error {
|
||||
service := mucp.NewService(
|
||||
service.Context(ctx),
|
||||
service.Name("foobar"),
|
||||
service.Registry(memory.NewRegistry()),
|
||||
service.AfterStart(func() error {
|
||||
wg.Done()
|
||||
return nil
|
||||
}),
|
||||
|
||||
@@ -10,16 +10,18 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/codec"
|
||||
"github.com/micro/go-micro/v2/codec/bytes"
|
||||
"github.com/micro/go-micro/v2/errors"
|
||||
"github.com/micro/go-micro/v2/logger"
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
"github.com/micro/go-micro/v2/proxy"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v2/selector/roundrobin"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
"github.com/micro/go-micro/v3/client"
|
||||
"github.com/micro/go-micro/v3/client/grpc"
|
||||
"github.com/micro/go-micro/v3/codec"
|
||||
"github.com/micro/go-micro/v3/codec/bytes"
|
||||
"github.com/micro/go-micro/v3/errors"
|
||||
"github.com/micro/go-micro/v3/logger"
|
||||
"github.com/micro/go-micro/v3/metadata"
|
||||
"github.com/micro/go-micro/v3/proxy"
|
||||
"github.com/micro/go-micro/v3/router"
|
||||
"github.com/micro/go-micro/v3/router/registry"
|
||||
"github.com/micro/go-micro/v3/selector/roundrobin"
|
||||
"github.com/micro/go-micro/v3/server"
|
||||
)
|
||||
|
||||
// Proxy will transparently proxy requests to an endpoint.
|
||||
@@ -593,12 +595,12 @@ func NewProxy(opts ...proxy.Option) proxy.Proxy {
|
||||
|
||||
// set the default client
|
||||
if p.Client == nil {
|
||||
p.Client = client.DefaultClient
|
||||
p.Client = grpc.NewClient()
|
||||
}
|
||||
|
||||
// create default router and start it
|
||||
if p.Router == nil {
|
||||
p.Router = router.DefaultRouter
|
||||
p.Router = registry.NewRouter()
|
||||
}
|
||||
// set the links
|
||||
if options.Links != nil {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v3/client"
|
||||
"github.com/micro/go-micro/v3/router"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
|
||||
@@ -4,7 +4,7 @@ package proxy
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
"github.com/micro/go-micro/v3/server"
|
||||
)
|
||||
|
||||
// Proxy can be used as a proxy server for go-micro services
|
||||
|
||||
Reference in New Issue
Block a user