rename wrap
This commit is contained in:
parent
0072b6e8f2
commit
651e9f8836
@ -24,6 +24,9 @@ import (
|
||||
"github.com/micro/go-micro/server"
|
||||
)
|
||||
|
||||
// Service is an interface that wraps the lower level libraries
|
||||
// within go-micro. Its a convenience method for building
|
||||
// and initialising services.
|
||||
type Service interface {
|
||||
Client() client.Client
|
||||
Server() server.Server
|
||||
|
@ -17,7 +17,7 @@ type service struct {
|
||||
func newService(opts ...Option) Service {
|
||||
options := newOptions(opts...)
|
||||
|
||||
options.Client = &clientWrap{
|
||||
options.Client = &clientWrapper{
|
||||
options.Client,
|
||||
context.Metadata{
|
||||
HeaderPrefix + "From-Service": options.Server.Config().Name(),
|
||||
|
@ -7,22 +7,22 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type clientWrap struct {
|
||||
type clientWrapper struct {
|
||||
client.Client
|
||||
headers cx.Metadata
|
||||
}
|
||||
|
||||
func (c *clientWrap) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
|
||||
func (c *clientWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
|
||||
ctx = cx.WithMetadata(ctx, c.headers)
|
||||
return c.Client.Call(ctx, req, rsp, opts...)
|
||||
}
|
||||
|
||||
func (c *clientWrap) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Streamer, error) {
|
||||
func (c *clientWrapper) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Streamer, error) {
|
||||
ctx = cx.WithMetadata(ctx, c.headers)
|
||||
return c.Client.Stream(ctx, req, opts...)
|
||||
}
|
||||
|
||||
func (c *clientWrap) Publish(ctx context.Context, p client.Publication, opts ...client.PublishOption) error {
|
||||
func (c *clientWrapper) Publish(ctx context.Context, p client.Publication, opts ...client.PublishOption) error {
|
||||
ctx = cx.WithMetadata(ctx, c.headers)
|
||||
return c.Client.Publish(ctx, p, opts...)
|
||||
}
|
Loading…
Reference in New Issue
Block a user