grpc

package
v0.0.0-...-4fe0d4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Copyright (c) 2015 Peter Bourgon Copyright (c) 2018 Gian Giovani

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NopRequestDecoder

func NopRequestDecoder(ctx context.Context, i interface{}) (interface{}, error)

NopRequestDecoder is a DecodeRequestFunc that can be used for requests that do not need to be decoded, and simply returns nil, nil.

Types

type DecodeRequestFunc

type DecodeRequestFunc func(context.Context, interface{}) (interface{}, error)

DecodeRequestFunc extracts a user-domain request object from an gRPC request object. It's designed to be used in gRPC servers, for server-side endpoints.

type EncodeResponseFunc

type EncodeResponseFunc func(context.Context, interface{}) (interface{}, error)

EncodeResponseFunc encodes the passed response object to the gRPC response writer. It's designed to be used in gRPC servers, for server-side endpoints.

type Handler

type Handler interface {
	ServeGRPC(context.Context, interface{}) (context.Context, interface{}, error)
}

Handler which should be called from the gRPC binding of the service implementation. The incoming request parameter, and returned response parameter, are both gRPC types, not user-domain.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server wraps an endpoint and implements http.Handler.

func New

func New(endpoint endpoint.Endpoint,
	dec DecodeRequestFunc,
	enc EncodeResponseFunc,
	options ...serverOption) *Server

New server instance which wrap and endpoint

func (*Server) ServeGRPC

func (s *Server) ServeGRPC(ctx context.Context, req interface{}) (retCtx context.Context, gRPCResponse interface{}, err error)

ServeGRPC implements Handler.ServeGRPC

Directories

Path Synopsis
test
pb
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL