Documentation ¶
Index ¶
- type Config
- type TService
- func (s *TService) ContextEndpoints() map[string]map[string]server.ContextHandlerFunc
- func (s *TService) ContextMiddleware(h server.ContextHandler) server.ContextHandler
- func (s *TService) Greeting(ctx ocontext.Context, r *pb.GreetingRequest) (*pb.GreetingResponse, error)
- func (s *TService) JSONEndpoints() map[string]map[string]server.JSONContextEndpoint
- func (s *TService) JSONMiddleware(j server.JSONContextEndpoint) server.JSONContextEndpoint
- func (s *TService) Middleware(h http.Handler) http.Handler
- func (s *TService) Prefix() string
- func (s *TService) Service() (*grpc.ServiceDesc, interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TService ¶
type TService struct {
Endpoints greeterendpoint.Endpoints
}
TService will implement server.RPCService and handle all requests to the server.
func NewTService ¶
func NewTService(cfg *Config, endpoints greeterendpoint.Endpoints) *TService
NewTService will instantiate a RPCService with the given configuration.
func (*TService) ContextEndpoints ¶
func (s *TService) ContextEndpoints() map[string]map[string]server.ContextHandlerFunc
ContextEndpoints may be needed if your server has any non-RPC-able endpoints. In this case, we have none but still need this method to satisfy the server.RPCService interface.
func (*TService) ContextMiddleware ¶
func (s *TService) ContextMiddleware(h server.ContextHandler) server.ContextHandler
ContextMiddleware provides a server.ContextHAndler hook wrapped around all requests. This could be handy if you need to decorate the request context.
func (*TService) Greeting ¶
func (s *TService) Greeting(ctx ocontext.Context, r *pb.GreetingRequest) (*pb.GreetingResponse, error)
Greeting implementation of the gRPC service.
func (*TService) JSONEndpoints ¶
func (s *TService) JSONEndpoints() map[string]map[string]server.JSONContextEndpoint
JSONEndpoints is a listing of all endpoints available in the TService.
func (*TService) JSONMiddleware ¶
func (s *TService) JSONMiddleware(j server.JSONContextEndpoint) server.JSONContextEndpoint
JSONMiddleware provides a JSONEndpoint hook wrapped around all requests. In this implementation, we're using it to provide application logging and to check errors and provide generic responses.
func (*TService) Middleware ¶
Middleware provides an http.Handler hook wrapped around all requests. In this implementation, we're using a GzipHandler middleware to compress our responses.
func (*TService) Prefix ¶
Prefix returns the string prefix used for all endpoints within this service.
func (*TService) Service ¶
func (s *TService) Service() (*grpc.ServiceDesc, interface{})
Service provides the TService with a description of the service to serve and the implementation.