2020-08-11 13:25:49 +03:00
|
|
|
package client
|
2015-12-21 02:50:16 +03:00
|
|
|
|
|
|
|
import (
|
2018-03-03 14:53:52 +03:00
|
|
|
"context"
|
|
|
|
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/client"
|
2015-12-21 02:50:16 +03:00
|
|
|
)
|
|
|
|
|
2020-06-05 12:18:35 +03: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
|
2020-08-11 13:25:49 +03:00
|
|
|
func Static(address string, c client.Client) client.Client {
|
2020-06-05 12:18:35 +03:00
|
|
|
return &staticClient{address, c}
|
|
|
|
}
|