Documentation ¶
Index ¶
- func ListenAndServe(r Registrator, setters ...Option) (err error)
- func NewListener(setters ...Option) (net.Listener, error)
- func NewServer(r Registrator, setters ...Option) *grpc.Server
- type Option
- func Config(o *tls.Config) Option
- func Network(o string) Option
- func Port(o int) Option
- func ServerOptions(o ...grpc.ServerOption) Option
- func SocketPath(o string) Option
- func WithDefaultLog() Option
- func WithLog(prefix string, w io.Writer) Option
- func WithReflection() Option
- func WithStreamInterceptor(i grpc.StreamServerInterceptor) Option
- func WithUnaryInterceptor(i grpc.UnaryServerInterceptor) Option
- type Options
- type Registrator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
func ListenAndServe(r Registrator, setters ...Option) (err error)
ListenAndServe configures TLS for mutual authentication by loading the CA into a CertPool and configuring the server's policy for TLS Client Authentication. Once TLS is configured, the gRPC options are built to make use of the TLS configuration and the receiver (Server) is registered to the gRPC server. Finally the gRPC server is started.
func NewListener ¶
NewListener builds listener for grpc server.
Types ¶
type Option ¶
type Option func(*Options)
Option is the functional option func.
func ServerOptions ¶
func ServerOptions(o ...grpc.ServerOption) Option
ServerOptions appends to the gRPC server options of the server.
func SocketPath ¶
SocketPath sets the listen unix file socket path of the server.
func WithDefaultLog ¶ added in v0.3.0
func WithDefaultLog() Option
WithDefaultLog sets up request logging to default destination.
func WithReflection ¶ added in v0.11.0
func WithReflection() Option
WithReflection enables gRPC reflection APIs: https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
func WithStreamInterceptor ¶ added in v0.3.0
func WithStreamInterceptor(i grpc.StreamServerInterceptor) Option
WithStreamInterceptor appends to the list of gRPC server stream interceptors.
func WithUnaryInterceptor ¶ added in v0.3.0
func WithUnaryInterceptor(i grpc.UnaryServerInterceptor) Option
WithUnaryInterceptor appends to the list of gRPC server unary interceptors.
type Options ¶
type Options struct { Port int SocketPath string Network string Config *tls.Config ServerOptions []grpc.ServerOption UnaryInterceptors []grpc.UnaryServerInterceptor StreamInterceptors []grpc.StreamServerInterceptor LogPrefix string LogDestination io.Writer Reflection bool }
Options is the functional options struct.
func NewDefaultOptions ¶
NewDefaultOptions initializes the Options struct with default values.
type Registrator ¶
Registrator describes the set of methods required in order for a concrete type to be used with the Listen function.