move location of handler
This commit is contained in:
		| @@ -1,37 +1,5 @@ | |||||||
| package server | package server | ||||||
|  |  | ||||||
| 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 |  | ||||||
| 	Options() HandlerOptions |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // 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{} |  | ||||||
| 	Endpoints() []*registry.Endpoint |  | ||||||
| 	Options() SubscriberOptions |  | ||||||
| } |  | ||||||
|  |  | ||||||
| type HandlerOptions struct { | type HandlerOptions struct { | ||||||
| 	Internal bool | 	Internal bool | ||||||
| 	Metadata map[string]map[string]string | 	Metadata map[string]map[string]string | ||||||
|   | |||||||
| @@ -9,8 +9,10 @@ import ( | |||||||
|  |  | ||||||
| 	"github.com/google/uuid" | 	"github.com/google/uuid" | ||||||
| 	"github.com/micro/go-log" | 	"github.com/micro/go-log" | ||||||
|  | 	"github.com/micro/go-micro/registry" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // Server is a simple micro server abstraction | ||||||
| type Server interface { | type Server interface { | ||||||
| 	Options() Options | 	Options() Options | ||||||
| 	Init(...Option) error | 	Init(...Option) error | ||||||
| @@ -25,12 +27,14 @@ type Server interface { | |||||||
| 	String() string | 	String() string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Message is an async message interface | ||||||
| type Message interface { | type Message interface { | ||||||
| 	Topic() string | 	Topic() string | ||||||
| 	Payload() interface{} | 	Payload() interface{} | ||||||
| 	ContentType() string | 	ContentType() string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Request is a synchronous request interface | ||||||
| type Request interface { | type Request interface { | ||||||
| 	Service() string | 	Service() string | ||||||
| 	Method() string | 	Method() string | ||||||
| @@ -43,7 +47,7 @@ type Request interface { | |||||||
| // Stream represents a stream established with a client. | // Stream represents a stream established with a client. | ||||||
| // A stream can be bidirectional which is indicated by the request. | // A stream can be bidirectional which is indicated by the request. | ||||||
| // The last error will be left in Error(). | // The last error will be left in Error(). | ||||||
| // EOF indicated end of the stream. | // EOF indicates end of the stream. | ||||||
| type Stream interface { | type Stream interface { | ||||||
| 	Context() context.Context | 	Context() context.Context | ||||||
| 	Request() Request | 	Request() Request | ||||||
| @@ -53,6 +57,34 @@ type Stream interface { | |||||||
| 	Close() error | 	Close() error | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Handler interface represents a 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 Greeter struct {} | ||||||
|  | // | ||||||
|  | //      func (g *Greeter) Hello(context, request, response) error { | ||||||
|  | //              return nil | ||||||
|  | //      } | ||||||
|  | // | ||||||
|  | type Handler interface { | ||||||
|  | 	Name() string | ||||||
|  | 	Handler() interface{} | ||||||
|  | 	Endpoints() []*registry.Endpoint | ||||||
|  | 	Options() HandlerOptions | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 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{} | ||||||
|  | 	Endpoints() []*registry.Endpoint | ||||||
|  | 	Options() SubscriberOptions | ||||||
|  | } | ||||||
|  |  | ||||||
| type Option func(*Options) | type Option func(*Options) | ||||||
|  |  | ||||||
| type HandlerOption func(*HandlerOptions) | type HandlerOption func(*HandlerOptions) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user