move implementations to external repos (#17)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-08-25 13:44:41 +03:00
committed by GitHub
parent c4a303190a
commit 0f4b1435d9
238 changed files with 151 additions and 37364 deletions

View File

@@ -4,7 +4,6 @@ import (
"github.com/unistack-org/micro/v3/api/resolver"
"github.com/unistack-org/micro/v3/api/resolver/vpath"
"github.com/unistack-org/micro/v3/registry"
"github.com/unistack-org/micro/v3/registry/mdns"
)
type Options struct {
@@ -17,8 +16,7 @@ type Option func(o *Options)
func NewOptions(opts ...Option) Options {
options := Options{
Handler: "meta",
Registry: mdns.NewRegistry(),
Handler: "meta",
}
for _, o := range opts {

View File

@@ -15,7 +15,6 @@ import (
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/registry"
"github.com/unistack-org/micro/v3/registry/cache"
util "github.com/unistack-org/micro/v3/util/router"
)
@@ -31,9 +30,6 @@ type registryRouter struct {
exit chan bool
opts router.Options
// registry cache
rc cache.Cache
sync.RWMutex
eps map[string]*api.Service
// compiled regexp for host and path
@@ -68,7 +64,7 @@ func (r *registryRouter) refresh() {
// for each service, get service and store endpoints
for _, s := range services {
service, err := r.rc.GetService(s.Name)
service, err := r.opts.Registry.GetService(s.Name)
if err != nil {
if logger.V(logger.ErrorLevel, logger.DefaultLogger) {
logger.Errorf("unable to get service: %v", err)
@@ -96,7 +92,7 @@ func (r *registryRouter) process(res *registry.Result) {
}
// get entry from cache
service, err := r.rc.GetService(res.Service.Name)
service, err := r.opts.Registry.GetService(res.Service.Name)
if err != nil {
if logger.V(logger.ErrorLevel, logger.DefaultLogger) {
logger.Errorf("unable to get %v service: %v", res.Service.Name, err)
@@ -283,7 +279,6 @@ func (r *registryRouter) Close() error {
return nil
default:
close(r.exit)
r.rc.Stop()
}
return nil
}
@@ -437,7 +432,7 @@ func (r *registryRouter) Route(req *http.Request) (*api.Service, error) {
name := rp.Name
// get service
services, err := r.rc.GetService(name, registry.GetDomain(rp.Domain))
services, err := r.opts.Registry.GetService(name, registry.GetDomain(rp.Domain))
if err != nil {
return nil, err
}
@@ -486,7 +481,6 @@ func newRouter(opts ...router.Option) *registryRouter {
r := &registryRouter{
exit: make(chan bool),
opts: options,
rc: cache.New(options.Registry),
eps: make(map[string]*api.Service),
ceps: make(map[string]*endpoint),
}

View File

@@ -1,3 +1,5 @@
// +build ignore
package router_test
import (