grapiserver

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: MIT Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Network string
	Addr    string
}

Address represents a network end point address.

type Config

type Config struct {
	GrpcAddr                        *Address
	GrpcInternalAddr                *Address
	GatewayAddr                     *Address
	Servers                         []Server
	GrpcServerUnaryInterceptors     []grpc.UnaryServerInterceptor
	GrpcServerStreamInterceptors    []grpc.StreamServerInterceptor
	GatewayServerUnaryInterceptors  []grpc.UnaryClientInterceptor
	GatewayServerStreamInterceptors []grpc.StreamClientInterceptor
	GrpcServerOption                []grpc.ServerOption
	GatewayDialOption               []grpc.DialOption
	GatewayMuxOptions               []runtime.ServeMuxOption
	GatewayServerConfig             *HTTPServerConfig
	MaxConcurrentStreams            uint32
	GatewayServerMiddlewares        []HTTPServerMiddleware
}

Config contains configurations of gRPC and Gateway server.

type Engine

type Engine struct {
	*Config
}

Engine is the framework instance.

func New

func New(opts ...Option) *Engine

New creates a server intstance.

func (*Engine) Serve

func (e *Engine) Serve(ctx context.Context) error

Serve starts gRPC and Gateway servers.

type HTTPServerConfig added in v0.3.0

type HTTPServerConfig struct {
	TLSConfig         *tls.Config
	ReadTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	MaxHeaderBytes    int
	TLSNextProto      map[string]func(*http.Server, *tls.Conn, http.Handler)
	ConnState         func(net.Conn, http.ConnState)
}

type HTTPServerMiddleware added in v0.1.3

type HTTPServerMiddleware func(http.Handler) http.Handler

HTTPServerMiddleware is an interface of http server middleware

type Option added in v0.2.0

type Option func(*Config)

Option configures a gRPC and a gateway server.

func WithAddr added in v0.2.0

func WithAddr(network, addr string) Option

WithAddr returns an Option that sets an network address for a gRPC and a gateway server.

func WithDefaultLogger added in v0.2.0

func WithDefaultLogger() Option

WithDefaultLogger returns an Option that sets default grpclogger.LoggerV2 object.

func WithGatewayAddr added in v0.2.0

func WithGatewayAddr(network, addr string) Option

WithGatewayAddr returns an Option that sets an network address for a gateway server.

func WithGatewayDialOptions added in v0.2.0

func WithGatewayDialOptions(opts ...grpc.DialOption) Option

WithGatewayDialOptions returns an Option that sets grpc.DialOption(s) to a gRPC clinet used by a gateway server.

func WithGatewayMuxOptions added in v0.2.0

func WithGatewayMuxOptions(opts ...runtime.ServeMuxOption) Option

WithGatewayMuxOptions returns an Option that sets runtime.ServeMuxOption(s) to a gateway server.

func WithGatewayServerConfig added in v0.3.0

func WithGatewayServerConfig(cfg *HTTPServerConfig) Option

WithGatewayServerConfig returns an Option that specifies http.Server configuration to a gateway server.

func WithGatewayServerMiddlewares added in v0.2.0

func WithGatewayServerMiddlewares(middlewares ...HTTPServerMiddleware) Option

WithGatewayServerMiddlewares returns an Option that sets middleware(s) for http.Server to a gateway server.

func WithGatewayServerStreamInterceptors added in v0.2.0

func WithGatewayServerStreamInterceptors(interceptors ...grpc.StreamClientInterceptor) Option

WithGatewayServerStreamInterceptors returns an Option that sets stream interceptor(s) for a gRPC client used by a gateway server.

func WithGatewayServerUnaryInterceptors added in v0.2.0

func WithGatewayServerUnaryInterceptors(interceptors ...grpc.UnaryClientInterceptor) Option

WithGatewayServerUnaryInterceptors returns an Option that sets unary interceptor(s) for a gRPC client used by a gateway server.

func WithGrpcAddr added in v0.2.0

func WithGrpcAddr(network, addr string) Option

WithGrpcAddr returns an Option that sets an network address for a gRPC server.

func WithGrpcInternalAddr added in v0.2.0

func WithGrpcInternalAddr(network, addr string) Option

WithGrpcInternalAddr returns an Option that sets an network address connected by a gateway server.

func WithGrpcServerOptions added in v0.2.0

func WithGrpcServerOptions(opts ...grpc.ServerOption) Option

WithGrpcServerOptions returns an Option that sets grpc.ServerOption(s) to a gRPC server.

func WithGrpcServerStreamInterceptors added in v0.2.0

func WithGrpcServerStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) Option

WithGrpcServerStreamInterceptors returns an Option that sets stream interceptor(s) for a gRPC server.

func WithGrpcServerUnaryInterceptors added in v0.2.0

func WithGrpcServerUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) Option

WithGrpcServerUnaryInterceptors returns an Option that sets unary interceptor(s) for a gRPC server.

func WithPassedHeader added in v0.2.0

func WithPassedHeader(decider PassedHeaderDeciderFunc) Option

WithPassedHeader returns an Option that sets configurations about passed headers for a gateway server.

func WithServers added in v0.2.0

func WithServers(svrs ...Server) Option

WithServers returns an Option that sets gRPC service server implementation(s).

type PassedHeaderDeciderFunc added in v0.1.3

type PassedHeaderDeciderFunc func(string) bool

PassedHeaderDeciderFunc returns true if given header should be passed to gRPC server metadata.

type Server

type Server interface {
	RegisterWithServer(*grpc.Server)
	RegisterWithHandler(context.Context, *runtime.ServeMux, *grpc.ClientConn) error
}

Server is an interface for representing gRPC server implementations.

Directories

Path Synopsis
testing
api
Package api_pb is a generated protocol buffer package.
Package api_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