Add some comments

This commit is contained in:
Asim 2015-12-01 18:41:43 +00:00
parent 6ca2cbadfc
commit d02986d1bd
2 changed files with 20 additions and 0 deletions

View File

@ -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{}

View File

@ -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)
}