diff --git a/go-micro.go b/go-micro.go index e8a091f0..384f862b 100644 --- a/go-micro.go +++ b/go-micro.go @@ -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 diff --git a/service.go b/service.go index 770e8b2c..4b2d8d91 100644 --- a/service.go +++ b/service.go @@ -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(), diff --git a/wrap.go b/wrapper.go similarity index 52% rename from wrap.go rename to wrapper.go index 671719d7..7757a27d 100644 --- a/wrap.go +++ b/wrapper.go @@ -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...) }