From d02986d1bd2fbb77d9aa4f2a62468a52c546a03e Mon Sep 17 00:00:00 2001 From: Asim Date: Tue, 1 Dec 2015 18:41:43 +0000 Subject: [PATCH] Add some comments --- server/handler.go | 11 +++++++++++ server/server.go | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/server/handler.go b/server/handler.go index 6021caef..57b8e7aa 100644 --- a/server/handler.go +++ b/server/handler.go @@ -4,12 +4,23 @@ import ( "github.com/micro/go-micro/registry" ) +// Handler interface represents a Service request handler. It's generated +// by passing any type of public concrete object with methods into server.NewHandler. +// Most will pass in a struct. +// Example: +// type Service struct {} +// func (s *Service) Method(context, request, response) error { +// return nil +// } +// type Handler interface { Name() string Handler() interface{} Endpoints() []*registry.Endpoint } +// Subscriber interface represents a subscription to a given topic using +// a specific subscriber function or object with methods. type Subscriber interface { Topic() string Subscriber() interface{} diff --git a/server/server.go b/server/server.go index b11c7522..3cbff857 100644 --- a/server/server.go +++ b/server/server.go @@ -66,6 +66,15 @@ func NewSubscriber(topic string, h interface{}) Subscriber { } // Creates a new handler interface using the default server +// Handlers are required to be a public object with public +// methods. Call to a service method such as Foo.Bar expects +// the type: +// +// type Foo struct {} +// func (f *Foo) Bar(ctx, req, rsp) error { +// return nil +// } +// func NewHandler(h interface{}) Handler { return DefaultServer.NewHandler(h) }