mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
move router
This commit is contained in:
parent
43ff2a540d
commit
4977aca09c
@ -7,8 +7,8 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/micro/go-micro/v2/client/selector"
|
||||
"github.com/micro/go-micro/v2/network/router"
|
||||
"github.com/micro/go-micro/v2/registry"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
)
|
||||
|
||||
type routerSelector struct {
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/micro/go-micro/v2"
|
||||
"github.com/micro/go-micro/v2/config"
|
||||
"github.com/micro/go-micro/v2/cmd"
|
||||
"github.com/micro/go-micro/v2/config"
|
||||
"github.com/micro/go-micro/v2/config/source"
|
||||
)
|
||||
|
||||
|
@ -17,12 +17,12 @@ import (
|
||||
rtr "github.com/micro/go-micro/v2/client/selector/router"
|
||||
"github.com/micro/go-micro/v2/logger"
|
||||
pbNet "github.com/micro/go-micro/v2/network/proto"
|
||||
"github.com/micro/go-micro/v2/network/proxy"
|
||||
"github.com/micro/go-micro/v2/network/resolver/dns"
|
||||
"github.com/micro/go-micro/v2/network/router"
|
||||
"github.com/micro/go-micro/v2/network/tunnel"
|
||||
bun "github.com/micro/go-micro/v2/network/tunnel/broker"
|
||||
tun "github.com/micro/go-micro/v2/network/tunnel/transport"
|
||||
"github.com/micro/go-micro/v2/network/proxy"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
smucp "github.com/micro/go-micro/v2/server/mucp"
|
||||
"github.com/micro/go-micro/v2/transport"
|
||||
|
@ -2,12 +2,12 @@ package network
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/micro/go-micro/v2/network/resolver"
|
||||
"github.com/micro/go-micro/v2/network/resolver/registry"
|
||||
"github.com/micro/go-micro/v2/network/tunnel"
|
||||
"github.com/micro/go-micro/v2/network/proxy"
|
||||
"github.com/micro/go-micro/v2/network/proxy/mucp"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v2/network/resolver"
|
||||
"github.com/micro/go-micro/v2/network/resolver/registry"
|
||||
"github.com/micro/go-micro/v2/network/router"
|
||||
"github.com/micro/go-micro/v2/network/tunnel"
|
||||
)
|
||||
|
||||
type Option func(*Options)
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"github.com/micro/go-micro/v2/logger"
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
"github.com/micro/go-micro/v2/network/proxy"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v2/network/router"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
)
|
||||
|
||||
|
@ -3,7 +3,7 @@ package proxy
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v2/network/router"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
|
@ -2,7 +2,7 @@ package network
|
||||
|
||||
import (
|
||||
pbNet "github.com/micro/go-micro/v2/network/proto"
|
||||
"github.com/micro/go-micro/v2/router"
|
||||
"github.com/micro/go-micro/v2/network/router"
|
||||
)
|
||||
|
||||
// routeToProto encodes route into protobuf and returns it
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
"github.com/micro/go-micro/v2/broker"
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/client/selector"
|
||||
"github.com/micro/go-micro/v2/config"
|
||||
"github.com/micro/go-micro/v2/cmd"
|
||||
"github.com/micro/go-micro/v2/config"
|
||||
"github.com/micro/go-micro/v2/debug/profile"
|
||||
"github.com/micro/go-micro/v2/debug/trace"
|
||||
"github.com/micro/go-micro/v2/registry"
|
||||
@ -155,7 +155,6 @@ func Tracer(t trace.Tracer) Option {
|
||||
func Auth(a auth.Auth) Option {
|
||||
return func(o *Options) {
|
||||
o.Auth = a
|
||||
o.Server.Init(server.Auth(a))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/micro/go-micro/v2/auth"
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/cmd"
|
||||
"github.com/micro/go-micro/v2/debug/service/handler"
|
||||
@ -34,21 +33,14 @@ func newService(opts ...Option) Service {
|
||||
// service name
|
||||
serviceName := options.Server.Options().Name
|
||||
|
||||
// we pass functions to the wrappers since the values can change during initialisation
|
||||
authFn := func() auth.Auth { return options.Server.Options().Auth }
|
||||
cacheFn := func() *client.Cache { return options.Client.Options().Cache }
|
||||
|
||||
// wrap client to inject From-Service header on any calls
|
||||
options.Client = wrapper.FromService(serviceName, options.Client)
|
||||
options.Client = wrapper.TraceCall(serviceName, trace.DefaultTracer, options.Client)
|
||||
options.Client = wrapper.CacheClient(cacheFn, options.Client)
|
||||
options.Client = wrapper.AuthClient(authFn, options.Client)
|
||||
|
||||
// wrap the server to provide handler stats
|
||||
options.Server.Init(
|
||||
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
|
||||
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTracer)),
|
||||
server.WrapHandler(wrapper.AuthHandler(authFn)),
|
||||
)
|
||||
|
||||
// set opts
|
||||
|
Loading…
Reference in New Issue
Block a user