Add some comments
This commit is contained in:
		| @@ -4,12 +4,23 @@ import ( | |||||||
| 	"github.com/micro/go-micro/registry" | 	"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 { | type Handler interface { | ||||||
| 	Name() string | 	Name() string | ||||||
| 	Handler() interface{} | 	Handler() interface{} | ||||||
| 	Endpoints() []*registry.Endpoint | 	Endpoints() []*registry.Endpoint | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Subscriber interface represents a subscription to a given topic using | ||||||
|  | // a specific subscriber function or object with methods. | ||||||
| type Subscriber interface { | type Subscriber interface { | ||||||
| 	Topic() string | 	Topic() string | ||||||
| 	Subscriber() interface{} | 	Subscriber() interface{} | ||||||
|   | |||||||
| @@ -66,6 +66,15 @@ func NewSubscriber(topic string, h interface{}) Subscriber { | |||||||
| } | } | ||||||
|  |  | ||||||
| // Creates a new handler interface using the default server | // 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 { | func NewHandler(h interface{}) Handler { | ||||||
| 	return DefaultServer.NewHandler(h) | 	return DefaultServer.NewHandler(h) | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user