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"
|
"sync"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v2/client/selector"
|
"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/registry"
|
||||||
"github.com/micro/go-micro/v2/router"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type routerSelector struct {
|
type routerSelector struct {
|
||||||
|
16
cmd/cmd.go
16
cmd/cmd.go
@ -321,9 +321,9 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultBrokers = map[string]func(...broker.Option) broker.Broker{
|
DefaultBrokers = map[string]func(...broker.Option) broker.Broker{
|
||||||
"memory": memory.NewBroker,
|
"memory": memory.NewBroker,
|
||||||
"nats": nats.NewBroker,
|
"nats": nats.NewBroker,
|
||||||
"http": brokerHttp.NewBroker,
|
"http": brokerHttp.NewBroker,
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultClients = map[string]func(...client.Option) client.Client{
|
DefaultClients = map[string]func(...client.Option) client.Client{
|
||||||
@ -332,9 +332,9 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
|
DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
|
||||||
"etcd": etcd.NewRegistry,
|
"etcd": etcd.NewRegistry,
|
||||||
"mdns": mdns.NewRegistry,
|
"mdns": mdns.NewRegistry,
|
||||||
"memory": rmem.NewRegistry,
|
"memory": rmem.NewRegistry,
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultSelectors = map[string]func(...selector.Option) selector.Selector{
|
DefaultSelectors = map[string]func(...selector.Option) selector.Selector{
|
||||||
@ -359,7 +359,7 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultStores = map[string]func(...store.Option) store.Store{
|
DefaultStores = map[string]func(...store.Option) store.Store{
|
||||||
"memory": memStore.NewStore,
|
"memory": memStore.NewStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultTracers = map[string]func(...trace.Option) trace.Tracer{
|
DefaultTracers = map[string]func(...trace.Option) trace.Tracer{
|
||||||
@ -368,7 +368,7 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultAuths = map[string]func(...auth.Option) auth.Auth{
|
DefaultAuths = map[string]func(...auth.Option) auth.Auth{
|
||||||
"jwt": jwtAuth.NewAuth,
|
"jwt": jwtAuth.NewAuth,
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultAuthProviders = map[string]func(...provider.Option) provider.Provider{
|
DefaultAuthProviders = map[string]func(...provider.Option) provider.Provider{
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/micro/cli/v2"
|
"github.com/micro/cli/v2"
|
||||||
"github.com/micro/go-micro/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/cmd"
|
||||||
|
"github.com/micro/go-micro/v2/config"
|
||||||
"github.com/micro/go-micro/v2/config/source"
|
"github.com/micro/go-micro/v2/config/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ import (
|
|||||||
rtr "github.com/micro/go-micro/v2/client/selector/router"
|
rtr "github.com/micro/go-micro/v2/client/selector/router"
|
||||||
"github.com/micro/go-micro/v2/logger"
|
"github.com/micro/go-micro/v2/logger"
|
||||||
pbNet "github.com/micro/go-micro/v2/network/proto"
|
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/resolver/dns"
|
||||||
|
"github.com/micro/go-micro/v2/network/router"
|
||||||
"github.com/micro/go-micro/v2/network/tunnel"
|
"github.com/micro/go-micro/v2/network/tunnel"
|
||||||
bun "github.com/micro/go-micro/v2/network/tunnel/broker"
|
bun "github.com/micro/go-micro/v2/network/tunnel/broker"
|
||||||
tun "github.com/micro/go-micro/v2/network/tunnel/transport"
|
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"
|
"github.com/micro/go-micro/v2/server"
|
||||||
smucp "github.com/micro/go-micro/v2/server/mucp"
|
smucp "github.com/micro/go-micro/v2/server/mucp"
|
||||||
"github.com/micro/go-micro/v2/transport"
|
"github.com/micro/go-micro/v2/transport"
|
||||||
|
@ -2,12 +2,12 @@ package network
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/uuid"
|
"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"
|
||||||
"github.com/micro/go-micro/v2/network/proxy/mucp"
|
"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)
|
type Option func(*Options)
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"github.com/micro/go-micro/v2/logger"
|
"github.com/micro/go-micro/v2/logger"
|
||||||
"github.com/micro/go-micro/v2/metadata"
|
"github.com/micro/go-micro/v2/metadata"
|
||||||
"github.com/micro/go-micro/v2/network/proxy"
|
"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"
|
"github.com/micro/go-micro/v2/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package proxy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/micro/go-micro/v2/client"
|
"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 {
|
type Options struct {
|
||||||
|
@ -2,7 +2,7 @@ package network
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
pbNet "github.com/micro/go-micro/v2/network/proto"
|
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
|
// 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/broker"
|
||||||
"github.com/micro/go-micro/v2/client"
|
"github.com/micro/go-micro/v2/client"
|
||||||
"github.com/micro/go-micro/v2/client/selector"
|
"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/cmd"
|
||||||
|
"github.com/micro/go-micro/v2/config"
|
||||||
"github.com/micro/go-micro/v2/debug/profile"
|
"github.com/micro/go-micro/v2/debug/profile"
|
||||||
"github.com/micro/go-micro/v2/debug/trace"
|
"github.com/micro/go-micro/v2/debug/trace"
|
||||||
"github.com/micro/go-micro/v2/registry"
|
"github.com/micro/go-micro/v2/registry"
|
||||||
@ -155,7 +155,6 @@ func Tracer(t trace.Tracer) Option {
|
|||||||
func Auth(a auth.Auth) Option {
|
func Auth(a auth.Auth) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Auth = a
|
o.Auth = a
|
||||||
o.Server.Init(server.Auth(a))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v2/auth"
|
|
||||||
"github.com/micro/go-micro/v2/client"
|
"github.com/micro/go-micro/v2/client"
|
||||||
"github.com/micro/go-micro/v2/cmd"
|
"github.com/micro/go-micro/v2/cmd"
|
||||||
"github.com/micro/go-micro/v2/debug/service/handler"
|
"github.com/micro/go-micro/v2/debug/service/handler"
|
||||||
@ -34,21 +33,14 @@ func newService(opts ...Option) Service {
|
|||||||
// service name
|
// service name
|
||||||
serviceName := options.Server.Options().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
|
// wrap client to inject From-Service header on any calls
|
||||||
options.Client = wrapper.FromService(serviceName, options.Client)
|
options.Client = wrapper.FromService(serviceName, options.Client)
|
||||||
options.Client = wrapper.TraceCall(serviceName, trace.DefaultTracer, 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
|
// wrap the server to provide handler stats
|
||||||
options.Server.Init(
|
options.Server.Init(
|
||||||
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
|
server.WrapHandler(wrapper.HandlerStats(stats.DefaultStats)),
|
||||||
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTracer)),
|
server.WrapHandler(wrapper.TraceHandler(trace.DefaultTracer)),
|
||||||
server.WrapHandler(wrapper.AuthHandler(authFn)),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// set opts
|
// set opts
|
||||||
|
@ -119,7 +119,7 @@ func (q *quicTransport) Dial(addr string, opts ...transport.DialOption) (transpo
|
|||||||
}
|
}
|
||||||
s, err := quic.DialAddr(addr, config, &quic.Config{
|
s, err := quic.DialAddr(addr, config, &quic.Config{
|
||||||
MaxIdleTimeout: time.Minute * 2,
|
MaxIdleTimeout: time.Minute * 2,
|
||||||
KeepAlive: true,
|
KeepAlive: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user