grpc

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 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 GRPCServer added in v0.6.0

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

func New

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

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

func (*GRPCServer) Register added in v0.6.0

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

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

func (*GRPCServer) Serve added in v0.6.0

func (s *GRPCServer) 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 (*GRPCServer) Stop added in v0.6.0

func (s *GRPCServer) 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 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 interface {
	server.Server       // Implements Serve and Stop.
	Register([]Service) // Registers the given services with this server.
}

Server is a gRPC server which will service gRPC requests.

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