grpcsrv

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

GRPC Server

The package core/workers/grpcsrv provides a default set of configuration for hosting a grpc server in a service.

Configuration

The GRPC server can be configured through these environment variables:

  • GRPC_ADDR the gRPC server listener's network address (default: 0.0.0.0:50051)

Examples

Starting server and exposing the service
srv := grpcsrv.New(&grpcsrv.Config{
    Addr: ":8080",
},
    grpc.StreamInterceptor(paginationmw.StreamServerInterceptor),
    grpc.UnaryInterceptor(paginationmw.UnaryServerInterceptor),
)
srv.Run(ctx)

Documentation

Overview

Package grpcsrv provides a default set of configuration for hosting a grpc server in a service.

Index

Constants

View Source
const (
	// Port is the default gRPC port used in examples.
	Port = 50051
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr string
}

Config represents configuration for the GRPC server.

type Server

type Server struct {
	Connection *grpc.Server
	Now        func() time.Time
	// contains filtered or unexported fields
}

Server represents a collection of functions for starting and running an RPC server.

func New

func New(config *Config, options ...grpc.ServerOption) *Server

New sets up a new grpc server.

func (*Server) Addr

func (gs *Server) Addr() *net.TCPAddr

Addr will block until you have received an address for your server.

func (*Server) Halt added in v0.21.0

func (gs *Server) Halt(_ context.Context) error

Halt will attempt to gracefully shut down the server.

func (*Server) Run

func (gs *Server) Run(_ context.Context) error

Run will start the gRPC server and listen for requests.

Jump to

Keyboard shortcuts

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