factory

package
v1.5.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

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

func NewListener(setters ...Option) (net.Listener, error)

NewListener builds listener for grpc server.

func NewServer

func NewServer(r Registrator, setters ...Option) *grpc.Server

NewServer builds grpc server and binds it to the Registrator.

func ServerGracefulStop

func ServerGracefulStop(server *grpc.Server, shutdownCtx context.Context)

ServerGracefulStop the server with a timeout.

Core gRPC doesn't support timeouts.

Types

type Option

type Option func(*Options)

Option is the functional option func.

func Address

func Address(a string) Option

Address sets the listen address of the server.

func Config

func Config(o *tls.Config) Option

Config sets the listen port of the server.

func Network

func Network(o string) Option

Network sets the network type of the listener.

func Port

func Port(o int) Option

Port sets the listen port of the server.

func ServerOptions

func ServerOptions(o ...grpc.ServerOption) Option

ServerOptions appends to the gRPC server options of the server.

func SocketPath

func SocketPath(o string) Option

SocketPath sets the listen unix file socket path of the server.

func WithDefaultLog

func WithDefaultLog() Option

WithDefaultLog sets up request logging to default destination.

func WithLog

func WithLog(prefix string, w io.Writer) Option

WithLog sets up request logging to specified destination.

func WithReflection

func WithReflection() Option

WithReflection enables gRPC reflection APIs: https://github.com/grpc/grpc/blob/master/doc/server-reflection.md

func WithStreamInterceptor

func WithStreamInterceptor(i grpc.StreamServerInterceptor) Option

WithStreamInterceptor appends to the list of gRPC server stream interceptors.

func WithUnaryInterceptor

func WithUnaryInterceptor(i grpc.UnaryServerInterceptor) Option

WithUnaryInterceptor appends to the list of gRPC server unary interceptors.

type Options

type Options struct {
	Address            string
	Port               int
	SocketPath         string
	Network            string
	Config             *tls.Config
	ServerOptions      []grpc.ServerOption
	UnaryInterceptors  []grpc.UnaryServerInterceptor
	StreamInterceptors []grpc.StreamServerInterceptor
	Reflection         bool
	// contains filtered or unexported fields
}

Options is the functional options struct.

func NewDefaultOptions

func NewDefaultOptions(setters ...Option) *Options

NewDefaultOptions initializes the Options struct with default values.

type Registrator

type Registrator interface {
	Register(*grpc.Server)
}

Registrator describes the set of methods required in order for a concrete type to be used with the Listen function.

Jump to

Keyboard shortcuts

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