Deprecate service (#1924)

This commit is contained in:
Asim Aslam
2020-08-11 10:03:47 +01:00
committed by GitHub
parent 1263806a39
commit d072eb6ff2
10 changed files with 15 additions and 1022 deletions

View File

@@ -5,14 +5,13 @@ import (
"fmt"
"net"
"net/http"
"sync"
"testing"
"github.com/micro/go-micro/v3/client"
cmucp "github.com/micro/go-micro/v3/client/mucp"
"github.com/micro/go-micro/v3/registry/memory"
"github.com/micro/go-micro/v3/server"
"github.com/micro/go-micro/v3/service"
"github.com/micro/go-micro/v3/service/mucp"
"github.com/micro/go-micro/v3/server/mucp"
)
type testHandler struct{}
@@ -53,37 +52,31 @@ func TestHTTPProxy(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var wg sync.WaitGroup
wg.Add(1)
reg := memory.NewRegistry()
// new micro service
service := mucp.NewService(
service.Context(ctx),
service.Name("foobar"),
service.Registry(memory.NewRegistry()),
service.AfterStart(func() error {
wg.Done()
return nil
}),
)
// set router
service.Server().Init(
service := mucp.NewServer(
server.Context(ctx),
server.Name("foobar"),
server.Registry(reg),
server.WithRouter(p),
)
service.Start()
defer service.Stop()
// run service
// server
go http.Serve(c, nil)
go service.Run()
// wait till service is started
wg.Wait()
cl := cmucp.NewClient(
client.Registry(reg),
)
for _, test := range testCases {
req := service.Client().NewRequest("foobar", test.rpcEp, map[string]string{"foo": "bar"}, client.WithContentType("application/json"))
req := cl.NewRequest("foobar", test.rpcEp, map[string]string{"foo": "bar"}, client.WithContentType("application/json"))
var rsp map[string]string
err := service.Client().Call(ctx, req, &rsp)
err := cl.Call(ctx, req, &rsp)
if err != nil && test.err == false {
t.Fatal(err)
}