2019-11-16 18:48:24 +00:00
|
|
|
package wrapper
|
2015-12-20 23:50:16 +00:00
|
|
|
|
|
|
|
import (
|
2018-03-03 11:53:52 +00:00
|
|
|
"context"
|
|
|
|
|
2020-07-27 13:22:00 +01:00
|
|
|
"github.com/micro/go-micro/v3/client"
|
2015-12-20 23:50:16 +00:00
|
|
|
)
|
|
|
|
|
2020-06-05 10:18:35 +01:00
|
|
|
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 StaticClient(address string, c client.Client) client.Client {
|
|
|
|
return &staticClient{address, c}
|
|
|
|
}
|