gogenserver

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGatewayServer

func NewGatewayServer(c *Config) internal.Server

NewGatewayServer creates GrpcServer instance.

func NewGrpcServer

func NewGrpcServer(c *Config) internal.Server

NewGrpcServer creates GrpcServer instance.

func NewMuxServer

func NewMuxServer(mux cmux.CMux, lis net.Listener) internal.Server

NewMuxServer creates MuxServer instance.

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
	// contains filtered or unexported fields
}

Engine is the framework instance.

func New

func New(opts ...Option) *Engine

New creates a server intstance.

func (*Engine) Serve

func (e *Engine) Serve() error

Serve starts gRPC and Gateway servers.

func (*Engine) Shutdown

func (e *Engine) Shutdown()

Shutdown closes servers.

type GatewayServer

type GatewayServer struct {
	*Config
	// contains filtered or unexported fields
}

GatewayServer wraps gRPC gateway server setup process.

func (*GatewayServer) Serve

func (s *GatewayServer) Serve(l net.Listener) error

Serve implements Server.Shutdown

func (*GatewayServer) Shutdown

func (s *GatewayServer) Shutdown()

Shutdown implements Server.Shutdown

type GrpcServer

type GrpcServer struct {
	*Config
	// contains filtered or unexported fields
}

GrpcServer wraps grpc.Server setup process.

func (*GrpcServer) Serve

func (s *GrpcServer) Serve(l net.Listener) error

Serve implements Server.Shutdown

func (*GrpcServer) Shutdown

func (s *GrpcServer) Shutdown()

Shutdown implements Server.Shutdown

type HTTPServerConfig

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

type HTTPServerMiddleware func(http.Handler) http.Handler

HTTPServerMiddleware is an interface of http server middleware

type MuxServer

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

MuxServer wraps a connection multiplexer and a listener.

func (*MuxServer) Serve

func (s *MuxServer) Serve(net.Listener) error

Serve implements Server.Serve

func (*MuxServer) Shutdown

func (s *MuxServer) Shutdown()

Shutdown implements Server.Shutdown

type Option

type Option func(*Config)

Option configures a gRPC and a gateway server.

func WithAddr

func WithAddr(network, addr string) Option

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

func WithDefaultLogger

func WithDefaultLogger() Option

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

func WithGatewayAddr

func WithGatewayAddr(network, addr string) Option

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

func WithGatewayDialOptions

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

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

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

func WithGatewayServerConfig

func WithGatewayServerConfig(cfg *HTTPServerConfig) Option

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

func WithGatewayServerMiddlewares

func WithGatewayServerMiddlewares(middlewares ...HTTPServerMiddleware) Option

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

func WithGatewayServerStreamInterceptors

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

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

func WithGrpcAddr(network, addr string) Option

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

func WithGrpcInternalAddr

func WithGrpcInternalAddr(network, addr string) Option

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

func WithGrpcServerOptions

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

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

func WithGrpcServerStreamInterceptors

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

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

func WithGrpcServerUnaryInterceptors

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

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

func WithPassedHeader

func WithPassedHeader(decider PassedHeaderDeciderFunc) Option

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

func WithServers

func WithServers(svrs ...Server) Option

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

type PassedHeaderDeciderFunc

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

Jump to

Keyboard shortcuts

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