move wrapper to client

This commit is contained in:
Asim Aslam 2020-08-11 11:25:49 +01:00
parent 28d6340f04
commit c51ef6fc29
2 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
package wrapper
package client
import (
"context"
@ -20,6 +20,6 @@ func (s *staticClient) Stream(ctx context.Context, req client.Request, opts ...c
}
// StaticClient sets an address on every call
func StaticClient(address string, c client.Client) client.Client {
func Static(address string, c client.Client) client.Client {
return &staticClient{address, c}
}

View File

@ -1,4 +1,4 @@
package wrapper_test
package client_test
import (
"context"
@ -14,7 +14,7 @@ import (
"github.com/micro/go-micro/v3/server"
grpcsrv "github.com/micro/go-micro/v3/server/grpc"
tmemory "github.com/micro/go-micro/v3/transport/memory"
wrapper "github.com/micro/go-micro/v3/util/wrapper"
cw "github.com/micro/go-micro/v3/util/client"
)
type TestFoo struct {
@ -31,7 +31,7 @@ func (h *TestFoo) Bar(ctx context.Context, req *TestReq, rsp *TestRsp) error {
return nil
}
func TestStaticClientWrapper(t *testing.T) {
func TestStaticClient(t *testing.T) {
var err error
req := grpc.NewClient().NewRequest(
@ -68,12 +68,12 @@ func TestStaticClientWrapper(t *testing.T) {
client.Transport(tr),
)
w1 := wrapper.StaticClient("xxx_localhost:12345", cli)
w1 := cw.Static("xxx_localhost:12345", cli)
if err = w1.Call(context.TODO(), req, nil); err == nil {
t.Fatal("address xxx_#localhost:12345 must not exists and call must be failed")
}
w2 := wrapper.StaticClient(srv.Options().Address, cli)
w2 := cw.Static(srv.Options().Address, cli)
if err = w2.Call(context.TODO(), req, rsp); err != nil {
t.Fatal(err)
} else if rsp.Data != "pass" {