grpc

package
Version: v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option provides options for configuring the creation of a gRPC server.

func WithInsecure

func WithInsecure() Option

WithInsecure will configure the server to allow insecure connections.

func WithLogger

func WithLogger(l log.Logger) Option

WithLogger will configure a unary server interceptor which provides logging of each gRPC request, and embeds a logger into the request's context.

func WithMetrics

func WithMetrics() Option

WithMetrics will configure a unary server interceptor which provides server side metrics.

func WithTracer

func WithTracer(t trace.Tracer) Option

WithTrace will configure a unary server interceptor which provides tracing of each gRPC request, and embeds trace info into the request's context.

func WithoutReflection

func WithoutReflection() Option

WithoutReflection disables the registration of the reflection service.

type Server

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

Server is a gRPC server which will service gRPC requests.

func New

func New(config server.Config, opts ...Option) (*Server, error)

New creates a gRPC server which has no service registered and has not started to accept requests yet.

func (*Server) Register

func (s *Server) Register(services []Service)

Register registers the given slices of services with the server. This must be called before invoking Server.

func (*Server) Serve

func (s *Server) Serve(result chan<- error)

Serve accepts incoming incoming connections, reads the gRPC requests and calls the registered service handlers to reply to them. This will return a non-nil error unless Stop is called.

func (*Server) Stop

func (s *Server) Stop()

Stop shuts down the gRPC server gracefully. It stops the server from accepting new connections and blocks until all the pending RPCs have completed.

type Service

type Service interface {
	// Register will register this service with the given gRPC server.
	Register(server *grpc.Server)

	// LogFields provides a set of log fields details.
	LogFields() map[string]interface{}
}

Service is an abstraction of a single gRPC service.

Directories

Path Synopsis
Package mockgrpc is a generated GoMock package.
Package mockgrpc is a generated GoMock package.

Jump to

Keyboard shortcuts

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