rename wrap

This commit is contained in:
Asim 2015-12-23 00:02:42 +00:00
parent 0072b6e8f2
commit 651e9f8836
3 changed files with 8 additions and 5 deletions

View File

@ -24,6 +24,9 @@ import (
"github.com/micro/go-micro/server" "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 { type Service interface {
Client() client.Client Client() client.Client
Server() server.Server Server() server.Server

View File

@ -17,7 +17,7 @@ type service struct {
func newService(opts ...Option) Service { func newService(opts ...Option) Service {
options := newOptions(opts...) options := newOptions(opts...)
options.Client = &clientWrap{ options.Client = &clientWrapper{
options.Client, options.Client,
context.Metadata{ context.Metadata{
HeaderPrefix + "From-Service": options.Server.Config().Name(), HeaderPrefix + "From-Service": options.Server.Config().Name(),

View File

@ -7,22 +7,22 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
) )
type clientWrap struct { type clientWrapper struct {
client.Client client.Client
headers cx.Metadata 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) ctx = cx.WithMetadata(ctx, c.headers)
return c.Client.Call(ctx, req, rsp, opts...) 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) ctx = cx.WithMetadata(ctx, c.headers)
return c.Client.Stream(ctx, req, opts...) 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) ctx = cx.WithMetadata(ctx, c.headers)
return c.Client.Publish(ctx, p, opts...) return c.Client.Publish(ctx, p, opts...)
} }