Shift embedded nats to the default

This commit is contained in:
Asim Aslam
2020-01-19 00:55:01 +00:00
parent 105596a0e5
commit 11b104677a
11 changed files with 1265 additions and 823 deletions

View File

@@ -8,23 +8,30 @@ import (
"time"
"github.com/micro/cli"
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/client/selector"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/store"
"github.com/micro/go-micro/util/log"
"github.com/micro/go-micro/runtime"
"github.com/micro/go-micro/transport"
// clients
cgrpc "github.com/micro/go-micro/client/grpc"
cmucp "github.com/micro/go-micro/client/mucp"
"github.com/micro/go-micro/server"
// servers
sgrpc "github.com/micro/go-micro/server/grpc"
smucp "github.com/micro/go-micro/server/mucp"
"github.com/micro/go-micro/util/log"
// brokers
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/broker/http"
"github.com/micro/go-micro/broker/memory"
"github.com/micro/go-micro/broker/nats"
brokerSrv "github.com/micro/go-micro/broker/service"
// registries
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/registry/etcd"
kreg "github.com/micro/go-micro/registry/kubernetes"
"github.com/micro/go-micro/registry/mdns"
@@ -32,27 +39,20 @@ import (
regSrv "github.com/micro/go-micro/registry/service"
// selectors
"github.com/micro/go-micro/client/selector"
"github.com/micro/go-micro/client/selector/dns"
"github.com/micro/go-micro/client/selector/router"
"github.com/micro/go-micro/client/selector/static"
// transports
"github.com/micro/go-micro/transport"
tgrpc "github.com/micro/go-micro/transport/grpc"
thttp "github.com/micro/go-micro/transport/http"
tmem "github.com/micro/go-micro/transport/memory"
"github.com/micro/go-micro/transport/quic"
// runtimes
"github.com/micro/go-micro/runtime"
"github.com/micro/go-micro/runtime/kubernetes"
// stores
"github.com/micro/go-micro/store"
cfStore "github.com/micro/go-micro/store/cloudflare"
ckStore "github.com/micro/go-micro/store/cockroach"
etcdStore "github.com/micro/go-micro/store/etcd"
memStore "github.com/micro/go-micro/store/memory"
svcStore "github.com/micro/go-micro/store/service"
)
@@ -217,7 +217,6 @@ var (
DefaultBrokers = map[string]func(...broker.Option) broker.Broker{
"service": brokerSrv.NewBroker,
"http": http.NewBroker,
"memory": memory.NewBroker,
"nats": nats.NewBroker,
}
@@ -236,9 +235,7 @@ var (
}
DefaultSelectors = map[string]func(...selector.Option) selector.Selector{
"default": selector.NewSelector,
"dns": dns.NewSelector,
"cache": selector.NewSelector,
"router": router.NewSelector,
"static": static.NewSelector,
}
@@ -251,8 +248,6 @@ var (
DefaultTransports = map[string]func(...transport.Option) transport.Transport{
"memory": tmem.NewTransport,
"http": thttp.NewTransport,
"grpc": tgrpc.NewTransport,
"quic": quic.NewTransport,
}
DefaultRuntimes = map[string]func(...runtime.Option) runtime.Runtime{
@@ -263,7 +258,6 @@ var (
DefaultStores = map[string]func(...store.Option) store.Store{
"memory": memStore.NewStore,
"cockroach": ckStore.NewStore,
"etcd": etcdStore.NewStore,
"cloudflare": cfStore.NewStore,
"service": svcStore.NewStore,
}
@@ -271,7 +265,7 @@ var (
// used for default selection as the fall back
defaultClient = "grpc"
defaultServer = "grpc"
defaultBroker = "nats"
defaultBroker = "enats"
defaultRegistry = "mdns"
defaultSelector = "registry"
defaultTransport = "http"
@@ -558,8 +552,12 @@ func (c *cmd) Init(opts ...Option) error {
for _, o := range opts {
o(&c.opts)
}
c.app.Name = c.opts.Name
c.app.Version = c.opts.Version
if len(c.opts.Name) > 0 {
c.app.Name = c.opts.Name
}
if len(c.opts.Version) > 0 {
c.app.Version = c.opts.Version
}
c.app.HideVersion = len(c.opts.Version) == 0
c.app.Usage = c.opts.Description
c.app.RunAndExitOnError()