grace

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolTCP4 = "tcp4"

Variables

This section is empty.

Functions

func ServeCron

func ServeCron(app *cron.Cron, graceTimeout time.Duration) error

ServeCron start the cron server on the given app and add graceful shutdown handler

func ServeGRPC

func ServeGRPC(server GRPCServer, address string, graceTimeout time.Duration) error

ServeGRPC start the gRPC server on the given address and add graceful shutdown handler

func ServeREST

func ServeREST(srv HTTPServer, address string, graceTimeout time.Duration) error

ServeREST start the http server on the given address and add graceful shutdown handler

func ServeRESTWithFiber

func ServeRESTWithFiber(app *fiber.App, address string, graceTimeout time.Duration) error

ServeRESTWithFiber start the http server using fiber on the given address and add graceful shutdown handler

func WaitTermSig

func WaitTermSig(handler func(context.Context) error) <-chan struct{}

WaitTermSig wait for termination signal and then execute the given handler The handler is usually transport shutdown, so we can properly shutdown our server upon SIGTERM. It returns channel which will be closed after the signal received and the handler executed. We can use the signal to wait for the shutdown to be finished.

Types

type GRPCServer

type GRPCServer interface {
	GracefulStop()
	Stop()
	Serve(l net.Listener) error
}

GRPCServer represents interface for grpc server

type HTTPServer

type HTTPServer interface {
	Shutdown(ctx context.Context) error
	Serve(l net.Listener) error
}

HTTPServer represents an HTTP server

Jump to

Keyboard shortcuts

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