From 5b381f13f03ef7e8c7d8b7ded470a2f1fdaf4a03 Mon Sep 17 00:00:00 2001 From: Asim Date: Sun, 19 Jun 2016 16:02:14 +0100 Subject: [PATCH] Add comments --- go-micro.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go-micro.go b/go-micro.go index 6defa0b8..d8f1309d 100644 --- a/go-micro.go +++ b/go-micro.go @@ -46,15 +46,18 @@ var ( HeaderPrefix = "X-Micro-" ) +// NewService creates an returns a new Service based on the packages within. func NewService(opts ...Option) Service { return newService(opts...) } +// FromContext retrieves a Service from the Context. func FromContext(ctx context.Context) (Service, bool) { s, ok := ctx.Value(serviceKey{}).(Service) return s, ok } +// NewContext returns a new Context with the Service embedded within it. func NewContext(ctx context.Context, s Service) context.Context { return context.WithValue(ctx, serviceKey{}, s) }