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

25
util/client/client.go Normal file
View File

@@ -0,0 +1,25 @@
package client
import (
"context"
"github.com/micro/go-micro/v3/client"
)
type staticClient struct {
address string
client.Client
}
func (s *staticClient) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
return s.Client.Call(ctx, req, rsp, append(opts, client.WithAddress(s.address))...)
}
func (s *staticClient) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error) {
return s.Client.Stream(ctx, req, append(opts, client.WithAddress(s.address))...)
}
// StaticClient sets an address on every call
func Static(address string, c client.Client) client.Client {
return &staticClient{address, c}
}