Add some comments
This commit is contained in:
parent
6ca2cbadfc
commit
d02986d1bd
@ -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{}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user