clair: github.com/coreos/clair/pkg/grpcutil Index | Files

package grpcutil

import "github.com/coreos/clair/pkg/grpcutil"

Package grpcutil implements various utilities around managing gRPC services.

Index

Package Files

gateway.go muxed_server.go server.go

func HandlerFunc Uses

func HandlerFunc(grpcServer *grpc.Server, otherwise http.Handler) http.Handler

HandlerFunc returns an http.Handler that delegates to grpc.Server on incoming gRPC connections otherwise serves with the provided handler.

func IsGRPCRequest Uses

func IsGRPCRequest(r *http.Request) bool

IsGRPCRequest returns true if the provided request came from a gRPC client.

Its logic is a partial recreation of gRPC's internal checks, see: https://github.com/grpc/grpc-go/blob/01de3de/transport/handler_server.go#L61:L69

func NewGateway Uses

func NewGateway(addr string, tlsConfig *tls.Config, funcs []RegisterServiceHandlerFunc) (http.Handler, *grpc.ClientConn, error)

NewGateway creates a new http.Handler and grpc.ClientConn with the provided gRPC Services registered.

func NewServer Uses

func NewServer(tlsConfig *tls.Config, fn RegisterServicesFunc) *grpc.Server

NewServer allocates a new grpc.Server and handles some some boilerplate configuration.

type MuxedGRPCServer Uses

type MuxedGRPCServer struct {
    Addr                string
    TLSConfig           *tls.Config
    ServicesFunc        RegisterServicesFunc
    ServiceHandlerFuncs []RegisterServiceHandlerFunc
}

MuxedGRPCServer defines the parameters for running a gRPC Server alongside a Gateway server on the same port.

func (*MuxedGRPCServer) ListenAndServe Uses

func (srv *MuxedGRPCServer) ListenAndServe(mw httputil.Middleware) error

ListenAndServe listens on the TCP network address srv.Addr and handles both gRPC and JSON requests over HTTP. An optional HTTP middleware can be provided to wrap the output of each request.

Internally, it muxes the Listener based on whether the request is gRPC or HTTP and runs multiple servers.

func (*MuxedGRPCServer) ListenAndServeTLS Uses

func (srv *MuxedGRPCServer) ListenAndServeTLS(certFile, keyFile, caPath string, mw httputil.Middleware) error

ListenAndServeTLS listens on the TCP network address srv.Addr and handles both gRPC and JSON requests over HTTP over TLS. An optional HTTP middleware can be provided to wrap the output of each request.

Internally, the same net.Listener is used because the http.Handler will pivot based on whether the request is gRPC or HTTP.

type RegisterServiceHandlerFunc Uses

type RegisterServiceHandlerFunc func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error

RegisterServiceHandlerFunc is a function that registers ServiceHandlers with a ServeMux.

type RegisterServicesFunc Uses

type RegisterServicesFunc func(*grpc.Server)

RegisterServicesFunc is a function that registers gRPC services with a given server.

Package grpcutil imports 13 packages (graph) and is imported by 3 packages. Updated 2019-03-16. Refresh now. Tools for package owners.