grpc

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package grpc provides opinionated production-ready configured gRPC server.

It includes error recovery, logger integration and optional telemetry instrument with following code sample:

Usage

grpc.NewServer(
  grpc.WithTelemetry(),
)(
  func(srv *grpc.Server) {
    // Register your server implementation here.
  },
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(handler func(*Server), opts ...ServerOption) func(context.Context) error

NewServer returns a gRPC server runner with provided ServerOption.

Types

type Server added in v0.2.0

type Server = grpc.Server

Server is alias of grpc.Server to simplify import.

type ServerOption

type ServerOption func(*serverOptions)

ServerOption configures how we run gRPC server.

func WithAddress

func WithAddress(address string) ServerOption

WithAddress specifies the address listened by gRPC server.

It could be either tcp address like :8080 or unix socket like unix:socket_path.

The default address is :8080.

func WithGRPCOptions added in v0.5.0

func WithGRPCOptions(opts ...grpc.ServerOption) ServerOption

WithGRPCOptions provides additional grpc.ServerOption for gRPC server.

func WithStopGate

func WithStopGate(gate func()) ServerOption

WithStopGate enables provided gate function blocks the shutdown of the gRPC server until it returns.

func WithTelemetry

func WithTelemetry(opts ...otelgrpc.Option) ServerOption

WithTelemetry enables trace and metric instrument on gRPC Server.

Jump to

Keyboard shortcuts

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