micro: rewrite options to support multiple building blocks

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-01-29 13:17:32 +03:00
parent ac8a3a12c4
commit 827d467077
57 changed files with 1283 additions and 644 deletions

View File

@@ -11,7 +11,7 @@ import (
"github.com/unistack-org/micro/v3/api"
"github.com/unistack-org/micro/v3/api/handler"
"github.com/unistack-org/micro/v3/registry"
"github.com/unistack-org/micro/v3/register"
)
const (
@@ -70,7 +70,7 @@ func (h *httpHandler) getService(r *http.Request) (string, error) {
}
// get the nodes for this service
nodes := make([]*registry.Node, 0, len(service.Services))
nodes := make([]*register.Node, 0, len(service.Services))
for _, srv := range service.Services {
nodes = append(nodes, srv.Nodes...)
}

View File

@@ -12,13 +12,13 @@ import (
"github.com/unistack-org/micro/v3/api/resolver"
"github.com/unistack-org/micro/v3/api/resolver/vpath"
"github.com/unistack-org/micro/v3/api/router"
regRouter "github.com/unistack-org/micro/v3/api/router/registry"
"github.com/unistack-org/micro/v3/registry"
"github.com/unistack-org/micro/v3/registry/memory"
regRouter "github.com/unistack-org/micro/v3/api/router/register"
"github.com/unistack-org/micro/v3/register"
"github.com/unistack-org/micro/v3/register/memory"
)
func testHttp(t *testing.T, path, service, ns string) {
r := memory.NewRegistry()
r := memory.NewRegister()
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
@@ -26,9 +26,9 @@ func testHttp(t *testing.T, path, service, ns string) {
}
defer l.Close()
s := &registry.Service{
s := &register.Service{
Name: service,
Nodes: []*registry.Node{
Nodes: []*register.Node{
{
Id: service + "-1",
Address: l.Addr().String(),
@@ -58,7 +58,7 @@ func testHttp(t *testing.T, path, service, ns string) {
// initialise the handler
rt := regRouter.NewRouter(
router.WithHandler("http"),
router.WithRegistry(r),
router.WithRegister(r),
router.WithResolver(vpath.NewResolver(
resolver.WithServicePrefix(ns),
)),

View File

@@ -14,7 +14,7 @@ import (
"github.com/unistack-org/micro/v3/api"
"github.com/unistack-org/micro/v3/api/handler"
"github.com/unistack-org/micro/v3/registry"
"github.com/unistack-org/micro/v3/register"
)
const (
@@ -72,7 +72,7 @@ func (wh *webHandler) getService(r *http.Request) (string, error) {
}
// get the nodes
nodes := make([]*registry.Node, 0, len(service.Services))
nodes := make([]*register.Node, 0, len(service.Services))
for _, srv := range service.Services {
nodes = append(nodes, srv.Nodes...)
}