From 0d917bbf37e76e9b6c3b9da043ac96d075f21aba Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Mon, 26 Nov 2018 14:51:42 +0000 Subject: [PATCH] move location of handler --- server/handler.go | 32 -------------------------------- server/server.go | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/server/handler.go b/server/handler.go index 5e81e5c3..336b6107 100644 --- a/server/handler.go +++ b/server/handler.go @@ -1,37 +1,5 @@ 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 { Internal bool Metadata map[string]map[string]string diff --git a/server/server.go b/server/server.go index 6a661266..cdbb4fca 100644 --- a/server/server.go +++ b/server/server.go @@ -9,8 +9,10 @@ import ( "github.com/google/uuid" "github.com/micro/go-log" + "github.com/micro/go-micro/registry" ) +// Server is a simple micro server abstraction type Server interface { Options() Options Init(...Option) error @@ -25,12 +27,14 @@ type Server interface { String() string } +// Message is an async message interface type Message interface { Topic() string Payload() interface{} ContentType() string } +// Request is a synchronous request interface type Request interface { Service() string Method() string @@ -43,7 +47,7 @@ type Request interface { // Stream represents a stream established with a client. // A stream can be bidirectional which is indicated by the request. // The last error will be left in Error(). -// EOF indicated end of the stream. +// EOF indicates end of the stream. type Stream interface { Context() context.Context Request() Request @@ -53,6 +57,34 @@ type Stream interface { 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 HandlerOption func(*HandlerOptions)