grpcserver

package module
v0.0.0-...-3f7e22d Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: MIT Imports: 14 Imported by: 0

README

gRPC Server

License

Installation

Use go get.

go get github.com/funcards/grpc-server

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

This section is empty.

Variables

Functions

func CtxWithLog

func CtxWithLog(ctx context.Context, log *zap.Logger) context.Context

func CtxWithNotify

func CtxWithNotify(ctx context.Context) (context.Context, context.CancelFunc)

func Exit

func Exit(err error, log *zap.Logger)

func LogFromCtx

func LogFromCtx(ctx context.Context) *zap.Logger

func MustLogFromCtx

func MustLogFromCtx(ctx context.Context) *zap.Logger

func Serve

func Serve(ctx context.Context, srvs ...func(ctx context.Context) error) error

Types

type Config

type Config struct {
	Network     string        `mapstructure:"network"`
	Address     string        `mapstructure:"address"`
	GracePeriod time.Duration `mapstructure:"grace_period"`
}

func (*Config) InitDefault

func (cfg *Config) InitDefault()

func (*Config) Listener

func (cfg *Config) Listener() (net.Listener, error)

type Server

type Server interface {
	RegisterService(desc *grpc.ServiceDesc, impl any)
	SetServingStatus(service string, status healthV1.HealthCheckResponse_ServingStatus)
	ListenAndServe(ctx context.Context) error
	Serve(lis net.Listener) error
	GracefulStop()
	Stop()
}

func New

func New(cfg Config, opts ...grpc.ServerOption) Server

Jump to

Keyboard shortcuts

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