grpc

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingJourney = errors.New("missing journey")

ErrMissingJourney occurs when there is an attempt to extract a journey from an incomming context that does not have it

Functions

func EmbedContext

func EmbedContext(ctx netcontext.Context) (netcontext.Context, error)

EmbedContext embeds a journey into a generic context

func ExtractContext

func ExtractContext(context netcontext.Context, app app.Ctx) (journey.Ctx, error)

ExtractContext extracts journey from a generic context

func MustDialOption

func MustDialOption(opt grpc.DialOption, err error) grpc.DialOption

MustDialOption panics if it receives an error

func WithMutualTLS

func WithMutualTLS(
	serverName, certFile, keyFile, caFile string,
) (grpc.DialOption, error)

WithMutualTLS returns a dial option for the GRPC client that activates a mutual TLS authentication between the server and the client.

func WithTLS

func WithTLS(
	certFile, serverNameOverride string,
) (grpc.DialOption, error)

WithTLS returns a dial option for the GRPC client that activates TLS. This must be used when the server has TLS activated.

Types

type Client

type Client struct {

	// HTTP is the standard net/http client
	GRPC *grpc.ClientConn
	// PropagateContext tells whether the journey should be propagated upstream
	//
	// This should be activated when the upstream endpoint is a LEGO service
	// or another LEGO-compatible service. The context can potentially leak
	// sensitive information, so do not activate it for services that you
	// don't trust.
	PropagateContext bool
	// contains filtered or unexported fields
}

Client is a wrapper for the grpc client.

func NewClient

func NewClient(
	appCtx app.Ctx, target string, opts ...grpc.DialOption,
) (*Client, error)

func (*Client) AppendUnaryMiddleware

func (c *Client) AppendUnaryMiddleware(m UnaryClientMiddleware)

func (*Client) Close

func (c *Client) Close() error

func (*Client) WaitForStateReady added in v1.3.1

func (c *Client) WaitForStateReady(ctx ctx.Ctx) error

WaitForStateReady waits until the connection is ready or the context times out

type Server

type Server struct {
	GRPC *grpc.Server
	// contains filtered or unexported fields
}

A Server defines parameters for running a lego compatible GRPC server

func NewServer

func NewServer() *Server

NewServer creates a new GRPC server

func (*Server) ActivateMutualTLS

func (s *Server) ActivateMutualTLS(certFile, keyFile, caFile string)

ActivateMutualTLS activates TLS on this handler. That means only incoming TLS connections are allowed and clients must authenticate themselves to the server.

If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.

func (*Server) ActivateTLS

func (s *Server) ActivateTLS(certFile, keyFile string)

ActivateTLS activates TLS on this handler. That means only incoming TLS connections are allowed.

If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.

Clients are not authenticated.

func (*Server) AppendUnaryMiddleware

func (s *Server) AppendUnaryMiddleware(m UnaryServerMiddleware)

AppendUnaryMiddleware appends an unary middleware to the call chain

func (*Server) Drain

func (s *Server) Drain()

Drain puts the handler into drain mode.

func (*Server) Handle

func (s *Server) Handle(f func(*grpc.Server))

Handle just injects the GRPC server to register a service. The function is called back only when Serve is called. This must be called before invoking Serve.

func (*Server) RegisterService

func (s *Server) RegisterService(sd *grpc.ServiceDesc, ss interface{})

RegisterService register a service and its implementation to the gRPC server. Called from the IDL generated code.

The function is called back only when Serve is called. This must be called before invoking Serve.

func (*Server) Serve

func (s *Server) Serve(addr string, ctx app.Ctx) error

Serve starts serving HTTP requests (blocking call)

func (*Server) SetOptions

func (s *Server) SetOptions(opts ...grpc.ServerOption)

SetOptions changes the handler options

type UnaryClientMiddleware

type UnaryClientMiddleware func(grpc.UnaryInvoker) grpc.UnaryInvoker

type UnaryHandler

type UnaryHandler func(ctx journey.Ctx, req interface{}) (interface{}, error)

type UnaryServerMiddleware

type UnaryServerMiddleware func(next UnaryHandler) UnaryHandler

Jump to

Keyboard shortcuts

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